parser: fix mutiple imports at one line (#24241)

This commit is contained in:
kbkpbot 2025-04-16 11:41:05 +08:00 committed by GitHub
parent c3d6858bf3
commit 422b89cb3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,5 @@
import math
import import as im
import os
import kitty as k
import ss

View File

@ -0,0 +1 @@
import math import import as im import os import kitty as k import ss

View File

@ -3869,7 +3869,7 @@ fn (mut p Parser) import_stmt() ast.Import {
}
pos_t := p.tok.pos()
if import_pos.line_nr == pos_t.line_nr {
if p.tok.kind !in [.lcbr, .eof, .comment, .semicolon] {
if p.tok.kind !in [.lcbr, .eof, .comment, .semicolon, .key_import] {
p.error_with_pos('cannot import multiple modules at a time', pos_t)
return import_node
}