mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: disable overriding and importing of builtin sym types (#16452)
This commit is contained in:
parent
cb9e945aa0
commit
360457e021
@ -2132,6 +2132,9 @@ fn (mut c Checker) import_stmt(node ast.Import) {
|
|||||||
c.error('module `${node.mod}` has no type `${sym.name}`', sym.pos)
|
c.error('module `${node.mod}` has no type `${sym.name}`', sym.pos)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if sym.name in ast.builtin_type_names {
|
||||||
|
c.error('cannot import or override builtin type', sym.pos)
|
||||||
|
}
|
||||||
if func := c.table.find_fn(name) {
|
if func := c.table.find_fn(name) {
|
||||||
if !func.is_pub {
|
if !func.is_pub {
|
||||||
c.error('module `${node.mod}` function `${sym.name}()` is private', sym.pos)
|
c.error('module `${node.mod}` function `${sym.name}()` is private', sym.pos)
|
||||||
|
11
vlib/v/checker/tests/import_sym_builtin_override_err.out
Normal file
11
vlib/v/checker/tests/import_sym_builtin_override_err.out
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
vlib/v/checker/tests/import_sym_builtin_override_err.vv:1:15: error: cannot import or override builtin type
|
||||||
|
1 | import rand { f64 }
|
||||||
|
| ~~~
|
||||||
|
2 |
|
||||||
|
3 | type Dot = [3]f64
|
||||||
|
vlib/v/checker/tests/import_sym_builtin_override_err.vv:3:12: error: unknown type `rand.f64`.
|
||||||
|
Did you mean `rand.PRNG`?
|
||||||
|
1 | import rand { f64 }
|
||||||
|
2 |
|
||||||
|
3 | type Dot = [3]f64
|
||||||
|
| ~~~~~~
|
3
vlib/v/checker/tests/import_sym_builtin_override_err.vv
Normal file
3
vlib/v/checker/tests/import_sym_builtin_override_err.vv
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import rand { f64 }
|
||||||
|
|
||||||
|
type Dot = [3]f64
|
Loading…
Reference in New Issue
Block a user