mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
6fd22531a9
commit
862d91ed0a
|
@ -1656,6 +1656,9 @@ fn (mut c Checker) global_decl(mut node ast.GlobalDecl) {
|
||||||
if field.name in c.global_names {
|
if field.name in c.global_names {
|
||||||
c.error('duplicate global `$field.name`', field.pos)
|
c.error('duplicate global `$field.name`', field.pos)
|
||||||
}
|
}
|
||||||
|
if '${c.mod}.$field.name' in c.const_names {
|
||||||
|
c.error('duplicate global and const `$field.name`', field.pos)
|
||||||
|
}
|
||||||
sym := c.table.sym(field.typ)
|
sym := c.table.sym(field.typ)
|
||||||
if sym.kind == .placeholder {
|
if sym.kind == .placeholder {
|
||||||
c.error('unknown type `$sym.name`', field.typ_pos)
|
c.error('unknown type `$sym.name`', field.typ_pos)
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
vlib/v/checker/tests/globals/name_conflict_with_const.vv:6:2: error: duplicate global and const `foo`
|
||||||
|
4 |
|
||||||
|
5 | __global (
|
||||||
|
6 | foo = 123
|
||||||
|
| ~~~
|
||||||
|
7 | )
|
7
vlib/v/checker/tests/globals/name_conflict_with_const.vv
Normal file
7
vlib/v/checker/tests/globals/name_conflict_with_const.vv
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
const (
|
||||||
|
foo = 'abc'
|
||||||
|
)
|
||||||
|
|
||||||
|
__global (
|
||||||
|
foo = 123
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user