parser/checker: fix global lookup
parent
c6573f9005
commit
2799a6f065
|
@ -1989,6 +1989,13 @@ pub fn (mut c Checker) ident(mut ident ast.Ident) table.Type {
|
|||
start_scope := c.file.scope.innermost(ident.pos.pos)
|
||||
if obj := start_scope.find(ident.name) {
|
||||
match obj {
|
||||
ast.GlobalDecl {
|
||||
ident.kind = .global
|
||||
ident.info = ast.IdentVar{
|
||||
typ: it.typ
|
||||
}
|
||||
return it.typ
|
||||
}
|
||||
ast.Var {
|
||||
mut typ := it.typ
|
||||
if typ == 0 {
|
||||
|
@ -2031,13 +2038,6 @@ pub fn (mut c Checker) ident(mut ident ast.Ident) table.Type {
|
|||
}
|
||||
if obj := c.file.global_scope.find(name) {
|
||||
match obj {
|
||||
ast.GlobalDecl {
|
||||
ident.kind = .global
|
||||
ident.info = ast.IdentVar{
|
||||
typ: it.typ
|
||||
}
|
||||
return it.typ
|
||||
}
|
||||
ast.ConstField {
|
||||
mut typ := it.typ
|
||||
if typ == 0 {
|
||||
|
|
|
@ -103,7 +103,7 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
|
|||
v_code := tmpl.compile_file(path)
|
||||
mut scope := &ast.Scope{
|
||||
start_pos: 0
|
||||
parent: 0
|
||||
parent: p.global_scope
|
||||
}
|
||||
file := parse_text(v_code, p.table, scope, p.global_scope)
|
||||
if p.pref.is_verbose {
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn parse_file(path string, b_table &table.Table, comments_mode scanner.Comme
|
|||
pref: pref
|
||||
scope: &ast.Scope{
|
||||
start_pos: 0
|
||||
parent: 0
|
||||
parent: global_scope
|
||||
}
|
||||
errors: []errors.Error{}
|
||||
warnings: []errors.Warning{}
|
||||
|
|
Loading…
Reference in New Issue