0 issues 1 contributor 4 branches 0 releases
Additions: 16 Deletions: 0 View patch
1 if field.name in c.global_names {
2 c.error('duplicate global `$field.name`', field.pos)
3 }
4+ if '${c.mod}.$field.name' in c.const_names {
5+ c.error('duplicate global and const `$field.name`', field.pos)
6+ }
7 sym := c.table.sym(field.typ)
8 if sym.kind == .placeholder {
9 c.error('unknown type `$sym.name`', field.typ_pos)
10
1new file mode 100644
2+vlib/v/checker/tests/globals/name_conflict_with_const.vv:6:2: error: duplicate global and const `foo`
3+ 4 |
4+ 5 | __global (
5+ 6 | foo = 123
6+ | ~~~
7+ 7 | )
8
1new file mode 100644
2+const (
3+ foo = 'abc'
4+)
5+
6+__global (
7+ foo = 123
8+)
9