Closed norayr closed 7 years ago
Would it make sense to warn when any built-in (predefined) type is redefined? Or just a subset?
In my opinion the issue is more general.
Redefinition of predefined constants, types and procedures/functions may cause code malfunctions or unexpected results. A warning makes sense for me, I expect this by an industrial quality compiler.
Type aliasing of predefined types leads to bizarre code like this:
MODULE test;
TYPE INTEGER = REAL;
VAR i : INTEGER;
BEGIN
i := 3.14
END test.
For this reason Wirth removed type aliasing in Oberon-07.
For the same reason TRUE, FALSE and NIL were promoted to keyword in Oberon-07 to avoid redefinition. OP2 (here) also promoted these constants to keywords, but Ofront seems to keep them as predefined constants, maybe because it doesn't reflect Oberon-2 report.
recent merge added 'redefining standard predefined type' warning. might not be implemented the best way though, but works.
5: INTEGER = REAL;
^
pos 68 warning 310 redefining standard predefined type
ok closing.
warn programmer when facing
or
alike type aliases. it is useful to know when compiling a module about those.