You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gen-ts/gen-js: a const named __NOT_EMITTED__, __DECL_ORDER__ or __STRUCT_ORDER__ makes the artifact redeclare it #6619
t27c gen-ts and t27c gen-js exit with rc 0 when a spec declares a const named __NOT_EMITTED__, __DECL_ORDER__ or __STRUCT_ORDER__. These are names every artifact exports itself, so the artifact binds the same name twice, and loading it fails:
module c {
pub const __NOT_EMITTED__ : u8 = 1;
}
$ t27c gen-ts in.t27 > a.ts # rc 0
export const __NOT_EMITTED__ = 1 satisfies number;
...
export const __NOT_EMITTED__ = Object.freeze([] as const);
$ node --experimental-strip-types h.ts # h.ts: import * as m from "./a.ts"
SyntaxError: Identifier '__NOT_EMITTED__' has already been declared
__DECL_ORDER__ and __STRUCT_ORDER__: a const with either name fails the same way under gen-ts.
gen-js: fails the same way.
gen-python: does not crash. The second assignment __NOT_EMITTED__ = [] silently replaces the spec's own value, so the artifact is wrong without any error.
This is present on master. It is not introduced by #6613, which only refuses these names for the opt-in --fn lowering (#6559).
Expected
Each declaration-level backend should either refuse the clashing declaration with a named reason (listed in __NOT_EMITTED__ or returned as an error), or refuse the whole file. The artifact must never bind its own bookkeeping names twice.
Given a spec file declaring pub const __NOT_EMITTED__ : u8 = 1;, when running t27c gen-ts on it, then the compiler must reject the declaration with a named error reason and exit non-zero.
Given a spec file declaring pub const __DECL_ORDER__ : u8 = 2;, when running t27c gen-js on it, then the compiler must reject the declaration with a named error reason and exit non-zero.
Given a spec file declaring pub const __STRUCT_ORDER__ : u8 = 3;, when running t27c gen-ts on it, then the compiler must reject the declaration with a named error reason and exit non-zero.
Requirements
FR-001: The compiler MUST reject any spec that declares a const named __NOT_EMITTED__, __DECL_ORDER__, or __STRUCT_ORDER__ when targeting gen-ts or gen-js.
FR-002: The rejection MUST produce a diagnostic that names the reserved identifier and the reason (artifact bookkeeping name clash).
FR-003: The compiler MUST exit with a non-zero code when such a declaration is present.
FR-004: The generated artifact MUST never contain duplicate bindings for __NOT_EMITTED__, __DECL_ORDER__, or __STRUCT_ORDER__.
Success Criteria
t27c gen-ts spec_not_emitted.t27 exits non-zero and prints a diagnostic containing __NOT_EMITTED__ and "reserved" (or equivalent) — bootstrap/src/compiler.rs
t27c gen-js spec_decl_order.t27 exits non-zero and prints a diagnostic containing __DECL_ORDER__ and "reserved" (or equivalent) — bootstrap/src/compiler.rs
t27c gen-ts spec_struct_order.t27 exits non-zero and prints a diagnostic containing __STRUCT_ORDER__ and "reserved" (or equivalent) — bootstrap/src/compiler.rs
Existing valid specs continue to compile: cargo test --package t27c -- gen_ts gen_js passes (5 tests) — bootstrap/src/compiler.rs
Activity