parser: check the redefinition of built-in IError (#13606)
parent
4215bb125c
commit
0fb1eaef04
|
@ -47,6 +47,10 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
|
||||||
name_pos)
|
name_pos)
|
||||||
return ast.StructDecl{}
|
return ast.StructDecl{}
|
||||||
}
|
}
|
||||||
|
if name == 'IError' && p.mod != 'builtin' {
|
||||||
|
p.error_with_pos('cannot register struct `IError`, it is builtin interface type',
|
||||||
|
name_pos)
|
||||||
|
}
|
||||||
generic_types, _ := p.parse_generic_types()
|
generic_types, _ := p.parse_generic_types()
|
||||||
no_body := p.tok.kind != .lcbr
|
no_body := p.tok.kind != .lcbr
|
||||||
if language == .v && no_body {
|
if language == .v && no_body {
|
||||||
|
@ -453,6 +457,10 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
|
||||||
name_pos := p.tok.pos()
|
name_pos := p.tok.pos()
|
||||||
p.check_for_impure_v(language, name_pos)
|
p.check_for_impure_v(language, name_pos)
|
||||||
modless_name := p.check_name()
|
modless_name := p.check_name()
|
||||||
|
if modless_name == 'IError' && p.mod != 'builtin' {
|
||||||
|
p.error_with_pos('cannot register interface `IError`, it is builtin interface type',
|
||||||
|
name_pos)
|
||||||
|
}
|
||||||
mut interface_name := ''
|
mut interface_name := ''
|
||||||
if language == .js {
|
if language == .js {
|
||||||
interface_name = 'JS.' + modless_name
|
interface_name = 'JS.' + modless_name
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
vlib/v/parser/tests/register_ierror_interface.vv:1:11: error: cannot register interface `IError`, it is builtin interface type
|
||||||
|
1 | interface IError {
|
||||||
|
| ~~~~~~
|
||||||
|
2 | foo() string
|
||||||
|
3 | }
|
|
@ -0,0 +1,7 @@
|
||||||
|
interface IError {
|
||||||
|
foo() string
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println('Hello World')
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
vlib/v/parser/tests/register_ierror_struct.vv:1:8: error: cannot register struct `IError`, it is builtin interface type
|
||||||
|
1 | struct IError {
|
||||||
|
| ~~~~~~
|
||||||
|
2 | msg string
|
||||||
|
3 | }
|
|
@ -0,0 +1,7 @@
|
||||||
|
struct IError {
|
||||||
|
msg string
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println('Hello World')
|
||||||
|
}
|
Loading…
Reference in New Issue