diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 8ce6ccbb84..bad0d16d0f 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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) 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.is_pub { c.error('module `${node.mod}` function `${sym.name}()` is private', sym.pos) diff --git a/vlib/v/checker/tests/import_sym_builtin_override_err.out b/vlib/v/checker/tests/import_sym_builtin_override_err.out new file mode 100644 index 0000000000..18bb0e90a3 --- /dev/null +++ b/vlib/v/checker/tests/import_sym_builtin_override_err.out @@ -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 + | ~~~~~~ diff --git a/vlib/v/checker/tests/import_sym_builtin_override_err.vv b/vlib/v/checker/tests/import_sym_builtin_override_err.vv new file mode 100644 index 0000000000..bdc0f1cc07 --- /dev/null +++ b/vlib/v/checker/tests/import_sym_builtin_override_err.vv @@ -0,0 +1,3 @@ +import rand { f64 } + +type Dot = [3]f64