parser: return node on incomplete module selector (#7574)

pull/7578/head
Ned Palacios 2020-12-26 18:23:51 +08:00 committed by GitHub
parent 1558bd1658
commit dfcbf31f65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1153,6 +1153,11 @@ pub fn (mut p Parser) name_expr() ast.Expr {
if p.peek_tok.kind == .dot &&
p.peek_tok2.kind != .eof && p.peek_tok2.lit.len > 0 && p.peek_tok2.lit[0].is_capital() {
is_mod_cast = true
} else if p.peek_tok.kind == .dot &&
p.peek_tok2.kind != .eof && p.peek_tok2.lit.len == 0 {
// incomplete module selector must be handled by dot_expr instead
node = p.parse_ident(language)
return node
}
}
// prepend the full import

View File

@ -1,4 +1,4 @@
vlib/v/parser/tests/uncomplete_module_call_err.vv:7:1: error: unexpected token ``
vlib/v/parser/tests/uncomplete_module_call_err.vv:7:1: error: unexpected `}`, expecting `name`
5 | fn main() {
6 | os.
7 | }