Added visibility checks to forward declarations
This commit is contained in:
parent
d16d4d5977
commit
f10d813414
|
@ -538,6 +538,8 @@ proc patchForwardDeclarations(self: BytecodeCompiler) =
|
||||||
var pos: array[8, uint8]
|
var pos: array[8, uint8]
|
||||||
for (forwarded, position) in self.forwarded:
|
for (forwarded, position) in self.forwarded:
|
||||||
impl = self.match(forwarded.ident.token.lexeme, forwarded.valueType, allowFwd=false)
|
impl = self.match(forwarded.ident.token.lexeme, forwarded.valueType, allowFwd=false)
|
||||||
|
if forwarded.isPrivate != impl.isPrivate:
|
||||||
|
self.error(&"implementation of '{impl.ident.token.lexeme}' has a mismatching visibility modifier from its forward declaration", impl.ident)
|
||||||
if position == 0:
|
if position == 0:
|
||||||
continue
|
continue
|
||||||
pos = impl.codePos.toLong()
|
pos = impl.codePos.toLong()
|
||||||
|
|
|
@ -10,3 +10,5 @@ print(foo() == 42);
|
||||||
|
|
||||||
fn foo: int {return 42;} # Commenting this line will cause an error
|
fn foo: int {return 42;} # Commenting this line will cause an error
|
||||||
|
|
||||||
|
# Note: The forward declaration and its corresponding implementation
|
||||||
|
# must have the same visibility!
|
Loading…
Reference in New Issue