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
JS backend silently merges distinct defs whose names mangle to the same identifier (C lane refuses the same program) #790
js_sat (comp.ts:2895) mangles def names to JS identifiers by replacing only [./~] with $. Distinct names can therefore collide — e.g. a user def helper.map.0 and a minted template instance helper.map~0 both become $helper$map$0$. The C lane detects exactly this and refuses to build ("two names mangle to", comp.ts:2751); js_lib has no equivalent check, so the two defs silently share one function and the later declaration wins.
C backend: prints 2 then 999 — correct, the two defs stay distinct.
JS backend: prints 2, then crashes with TypeError: Invalid mix of BigInt and other type in division. — one function now serves two different defs, so one of the call sites executes the wrong body.
Also reproducible with module names (net/irc vs net.irc, bend.ts canonical names) and any user def whose name matches template~N.
Expected
Either run the same duplicate detection in js_lib (die on collision, mirroring compile_tables) or make js_sat injective (encode separators positionally).
Fixed in 2.0.6: the JS emitter now refuses two defs whose names mangle to the same identifier ("two names mangle to $helper$map$0$"), mirroring the C lane's check. Your helper.map.0 vs the minted helper.map~0 was exactly the collision.
Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.
Activity
VictorTaelin commentedon Sep 18, 2026
Fixed in 2.0.6: the JS emitter now refuses two defs whose names mangle to the same identifier ("two names mangle to $helper$map$0$"), mirroring the C lane's check. Your
helper.map.0vs the mintedhelper.map~0was exactly the collision.Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.