The program/unit's own name and the names of directly used units can no longer be redeclared by top-level declarations, matching FPC and Delphi (Duplicate identifier / E2004). Previously the module name was stored on the AST node and never entered the symbol table, so 'program P; var P: Integer;' compiled by accident of omission. The semantic pass plants skModule marker symbols in the scopes that receive top-level declarations (global + program-block scope for programs, unit scope for units); the ordinary duplicate check on TSymbolTable.Define then rejects redeclarations. Lookup treats a marker hit as unresolvable, so the reserved name is not a value and inner scopes can still shadow it, as in FPC. The const paths get an explicit marker check because their Define-failure branch otherwise tolerates the clash silently (cross-unit const shadowing). One deliberate divergence: FPC accepts a procedure named after the program (an accident of its overload machinery); Blaise rejects all declaration forms uniformly. Grammar is unchanged — this is a name-resolution rule, not syntax — so grammar.ebnf is untouched; the decision is recorded in language-rationale.adoc. 44 test programs named 'program P' that also declared an identifier P are renamed to 'program Prg'. Closes #84 |
||
|---|---|---|
| .. | ||
| benchmark.txt | ||
| bif-format.adoc | ||
| design.adoc | ||
| extending-ast.adoc | ||
| future-improvements.adoc | ||
| grammar.ebnf | ||
| language-rationale.adoc | ||
| name-mangling.adoc | ||
| native-const-arg-arc-port.adoc | ||
| testing-strategy.adoc | ||