1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix fibonacci in silent mode (#7240)

This commit is contained in:
Daniel Däschle 2020-12-10 17:17:25 +01:00 committed by GitHub
parent 916a64935a
commit 1c56ff7faf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -608,3 +608,4 @@ jobs:
run: |
./v test-parser examples/hello_world.v
./v test-parser examples/hanoi.v
./v test-parser examples/fibonacci.v

View File

@ -13,7 +13,7 @@ fn main() {
args := os.args[1..self_idx]
jargs := args.join(' ')
obinary := cmdline.option(args, '-o', '')
sargs := if obinary != '' { jargs } else { '$jargs -o v2 ' }
sargs := if obinary != '' { jargs } else { '$jargs -o v2' }
cmd := '$vexe $sargs cmd/v'
options := if args.len > 0 { '($sargs)' } else { '' }
println('V self compiling ${options}...')

View File

@ -1132,7 +1132,8 @@ pub fn (mut p Parser) name_expr() ast.Expr {
if p.tok.lit in p.imports {
// mark the imported module as used
p.register_used_import(p.tok.lit)
if p.peek_tok.kind == .dot && p.peek_tok2.lit[0].is_capital() {
if p.peek_tok.kind == .dot &&
p.peek_tok2.kind != .eof && p.peek_tok2.lit[0].is_capital() {
is_mod_cast = true
}
}
@ -1143,7 +1144,7 @@ pub fn (mut p Parser) name_expr() ast.Expr {
p.check(.dot)
p.expr_mod = mod
}
lit0_is_capital := p.tok.lit[0].is_capital()
lit0_is_capital := if p.tok.kind != .eof { p.tok.lit[0].is_capital() } else { false }
// use heuristics to detect `func<T>()` from `var < expr`
is_generic_call := !lit0_is_capital && p.peek_tok.kind == .lt && (match p.peek_tok2.kind {
.name {

View File

@ -798,7 +798,7 @@ fn (mut s Scanner) text_scan() token.Token {
`.` {
if nextc == `.` {
s.pos++
if s.text[s.pos + 1] == `.` {
if s.pos + 1 < s.text.len && s.text[s.pos + 1] == `.` {
s.pos++
return s.new_token(.ellipsis, '', 3)
}