mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: silent mode fixes (#7286)
This commit is contained in:
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
|
||||
expr_type := c.expr(expr)
|
||||
if expr_type.idx() == 0 {
|
||||
// parser failed, stop checking
|
||||
return
|
||||
}
|
||||
if cond_type_sym.kind == .interface_ {
|
||||
// TODO
|
||||
// This generates a memory issue with TCC
|
||||
|
@ -173,7 +173,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
|
||||
p.next()
|
||||
} 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.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{}
|
||||
for {
|
||||
// Sum type match
|
||||
|
@ -48,6 +48,10 @@ pub fn (mut p Parser) parse_map_type() table.Type {
|
||||
}
|
||||
p.check(.lsbr)
|
||||
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)
|
||||
// if key_type_sym.kind != .string {
|
||||
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)
|
||||
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)
|
||||
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{}
|
||||
for p.tok.kind != .eof {
|
||||
mr_type := p.parse_type()
|
||||
if mr_type.idx() == 0 {
|
||||
break
|
||||
}
|
||||
mr_types << mr_type
|
||||
if p.tok.kind == .comma {
|
||||
p.next()
|
||||
|
@ -1021,14 +1021,10 @@ pub fn (mut p Parser) parse_ident(language table.Language) ast.Ident {
|
||||
}
|
||||
scope: p.scope
|
||||
}
|
||||
} else {
|
||||
p.error('unexpected token `$p.tok.lit`')
|
||||
return ast.Ident{
|
||||
scope: 0
|
||||
}
|
||||
}
|
||||
p.error('unexpected token `$p.tok.lit`')
|
||||
return ast.Ident{
|
||||
scope: 0
|
||||
scope: p.scope
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user