mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: use type unresolved
for unresolved consts
This commit is contained in:
parent
bf9f3057da
commit
ec025f2020
@ -756,9 +756,9 @@ fn (p mut Parser) const_decl() {
|
|||||||
if p.first_pass() {
|
if p.first_pass() {
|
||||||
p.table.register_const(name, typ, p.mod, is_pub)
|
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 := p.v.table.find_const(name) {
|
||||||
if my_const.typ == 'void' {
|
if my_const.typ == 'unresolved' {
|
||||||
for i, v in p.v.table.consts {
|
for i, v in p.v.table.consts {
|
||||||
if v.name == name {
|
if v.name == name {
|
||||||
p.v.table.consts[i].typ = typ
|
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.
|
// First pass, the function can be defined later.
|
||||||
if p.first_pass() {
|
if p.first_pass() {
|
||||||
p.next()
|
p.next()
|
||||||
return 'void'
|
return 'unresolved'
|
||||||
}
|
}
|
||||||
// exhaused all options type,enum,const,mod,var,fn etc
|
// exhaused all options type,enum,const,mod,var,fn etc
|
||||||
// so show undefined error (also checks typos)
|
// 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.cgen.set_placeholder(ph, '${typ}_${cpostfix}(')
|
||||||
p.gen(')')
|
p.gen(')')
|
||||||
}
|
}
|
||||||
else {
|
else if typ != 'unresolved' {
|
||||||
p.error('operator $op not defined on `$typ`')
|
p.error('operator $op not defined on `$typ`')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ pub const (
|
|||||||
// c = a // TODO
|
// c = a // TODO
|
||||||
a = b
|
a = b
|
||||||
b = 1
|
b = 1
|
||||||
|
d = (e / 2) + 7
|
||||||
|
e = 9
|
||||||
)
|
)
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
@ -10,5 +12,6 @@ struct Foo {
|
|||||||
|
|
||||||
fn test_const() {
|
fn test_const() {
|
||||||
assert a == 1
|
assert a == 1
|
||||||
|
assert d == 11
|
||||||
// assert c == 1 // TODO: This will not build yet
|
// assert c == 1 // TODO: This will not build yet
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user