diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9935fc44a8..09d2ba7480 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -611,3 +611,4 @@ jobs: ./v test-parser examples/fibonacci.v ./v test-parser examples/cli.v ./v test-parser examples/json.v + ./v test-parser examples/vmod.v diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index a1c781e83c..e19b765ce0 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1140,7 +1140,7 @@ pub fn (mut p Parser) name_expr() ast.Expr { p.check(.dot) p.expr_mod = mod } - lit0_is_capital := if p.tok.kind != .eof { p.tok.lit[0].is_capital() } else { false } + lit0_is_capital := if p.tok.kind != .eof && p.tok.lit.len > 0 { p.tok.lit[0].is_capital() } else { false } // use heuristics to detect `func()` from `var < expr` is_generic_call := !lit0_is_capital && p.peek_tok.kind == .lt && (match p.peek_tok2.kind { .name { diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index f0608dc4cf..7406c51014 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -763,8 +763,11 @@ fn (mut s Scanner) text_scan() token.Token { return s.new_token(.comma, '', 1) } `@` { - s.pos++ - name := s.ident_name() + mut name := '' + if nextc != `\0` { + s.pos++ + name = s.ident_name() + } if s.is_fmt { return s.new_token(.name, '@' + name, name.len + 1) }