compiler: use type `unresolved` for unresolved consts
parent
bf9f3057da
commit
ec025f2020
|
@ -756,9 +756,9 @@ fn (p mut Parser) const_decl() {
|
|||
if p.first_pass() {
|
||||
p.table.register_const(name, typ, p.mod, is_pub)
|
||||
}
|
||||
// Check to see if this constant exists, and is void. If so, try and get the type again:
|
||||
// Check to see if this constant exists, and is unresolved. If so, try and get the type again:
|
||||
if my_const := p.v.table.find_const(name) {
|
||||
if my_const.typ == 'void' {
|
||||
if my_const.typ == 'unresolved' {
|
||||
for i, v in p.v.table.consts {
|
||||
if v.name == name {
|
||||
p.v.table.consts[i].typ = typ
|
||||
|
|
|
@ -457,7 +457,7 @@ fn (p mut Parser) name_expr() string {
|
|||
// First pass, the function can be defined later.
|
||||
if p.first_pass() {
|
||||
p.next()
|
||||
return 'void'
|
||||
return 'unresolved'
|
||||
}
|
||||
// exhaused all options type,enum,const,mod,var,fn etc
|
||||
// so show undefined error (also checks typos)
|
||||
|
@ -680,7 +680,7 @@ fn (p mut Parser) handle_operator(op string, typ string,cpostfix string, ph int,
|
|||
p.cgen.set_placeholder(ph, '${typ}_${cpostfix}(')
|
||||
p.gen(')')
|
||||
}
|
||||
else {
|
||||
else if typ != 'unresolved' {
|
||||
p.error('operator $op not defined on `$typ`')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ pub const (
|
|||
// c = a // TODO
|
||||
a = b
|
||||
b = 1
|
||||
d = (e / 2) + 7
|
||||
e = 9
|
||||
)
|
||||
|
||||
struct Foo {
|
||||
|
@ -10,5 +12,6 @@ struct Foo {
|
|||
|
||||
fn test_const() {
|
||||
assert a == 1
|
||||
assert d == 11
|
||||
// assert c == 1 // TODO: This will not build yet
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue