parser: silent mode fixes (#7286)
parent
1ff6230062
commit
b76c91ec05
|
@ -3565,6 +3565,10 @@ fn (mut c Checker) match_exprs(mut node ast.MatchExpr, type_sym table.TypeSymbol
|
||||||
}
|
}
|
||||||
c.expected_type = node.cond_type
|
c.expected_type = node.cond_type
|
||||||
expr_type := c.expr(expr)
|
expr_type := c.expr(expr)
|
||||||
|
if expr_type.idx() == 0 {
|
||||||
|
// parser failed, stop checking
|
||||||
|
return
|
||||||
|
}
|
||||||
if cond_type_sym.kind == .interface_ {
|
if cond_type_sym.kind == .interface_ {
|
||||||
// TODO
|
// TODO
|
||||||
// This generates a memory issue with TCC
|
// This generates a memory issue with TCC
|
||||||
|
|
|
@ -173,7 +173,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
|
||||||
p.next()
|
p.next()
|
||||||
} else if p.tok.kind == .name && !(p.tok.lit == 'C' &&
|
} else if p.tok.kind == .name && !(p.tok.lit == 'C' &&
|
||||||
p.peek_tok.kind == .dot) && (p.tok.lit in table.builtin_type_names || p.tok.lit[0].is_capital() ||
|
p.peek_tok.kind == .dot) && (p.tok.lit in table.builtin_type_names || p.tok.lit[0].is_capital() ||
|
||||||
(p.peek_tok.kind == .dot && p.peek_tok2.lit[0].is_capital())) {
|
(p.peek_tok.kind == .dot && p.peek_tok2.lit.len > 0 && p.peek_tok2.lit[0].is_capital())) {
|
||||||
mut types := []table.Type{}
|
mut types := []table.Type{}
|
||||||
for {
|
for {
|
||||||
// Sum type match
|
// Sum type match
|
||||||
|
|
|
@ -48,6 +48,10 @@ pub fn (mut p Parser) parse_map_type() table.Type {
|
||||||
}
|
}
|
||||||
p.check(.lsbr)
|
p.check(.lsbr)
|
||||||
key_type := p.parse_type()
|
key_type := p.parse_type()
|
||||||
|
if key_type.idx() == 0 {
|
||||||
|
// error is reported in parse_type
|
||||||
|
return 0
|
||||||
|
}
|
||||||
// key_type_sym := p.get_type_symbol(key_type)
|
// key_type_sym := p.get_type_symbol(key_type)
|
||||||
// if key_type_sym.kind != .string {
|
// if key_type_sym.kind != .string {
|
||||||
if key_type.idx() != table.string_type_idx {
|
if key_type.idx() != table.string_type_idx {
|
||||||
|
@ -56,6 +60,10 @@ pub fn (mut p Parser) parse_map_type() table.Type {
|
||||||
}
|
}
|
||||||
p.check(.rsbr)
|
p.check(.rsbr)
|
||||||
value_type := p.parse_type()
|
value_type := p.parse_type()
|
||||||
|
if value_type.idx() == 0 {
|
||||||
|
// error is reported in parse_type
|
||||||
|
return 0
|
||||||
|
}
|
||||||
idx := p.table.find_or_register_map(key_type, value_type)
|
idx := p.table.find_or_register_map(key_type, value_type)
|
||||||
return table.new_type(idx)
|
return table.new_type(idx)
|
||||||
}
|
}
|
||||||
|
@ -78,6 +86,9 @@ pub fn (mut p Parser) parse_multi_return_type() table.Type {
|
||||||
mut mr_types := []table.Type{}
|
mut mr_types := []table.Type{}
|
||||||
for p.tok.kind != .eof {
|
for p.tok.kind != .eof {
|
||||||
mr_type := p.parse_type()
|
mr_type := p.parse_type()
|
||||||
|
if mr_type.idx() == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
mr_types << mr_type
|
mr_types << mr_type
|
||||||
if p.tok.kind == .comma {
|
if p.tok.kind == .comma {
|
||||||
p.next()
|
p.next()
|
||||||
|
|
|
@ -1021,14 +1021,10 @@ pub fn (mut p Parser) parse_ident(language table.Language) ast.Ident {
|
||||||
}
|
}
|
||||||
scope: p.scope
|
scope: p.scope
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
p.error('unexpected token `$p.tok.lit`')
|
p.error('unexpected token `$p.tok.lit`')
|
||||||
return ast.Ident{
|
return ast.Ident{
|
||||||
scope: 0
|
scope: p.scope
|
||||||
}
|
|
||||||
}
|
|
||||||
return ast.Ident{
|
|
||||||
scope: 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue