testGlobalsAndLocalsAreDistinguished
Globals and locals with the same name are distinguished.
import { hashes } from "#codebase/tcmts/core/test/hash"; import assert from "node:assert/strict"; export const testGlobalsAndLocalsAreDistinguished = () => { // the same code but for whether `Math` is the global or the parameter (parameters' names aren't hashed) const T = `{ max: (a: number, b: number) => number }`; const global = hashes(`const f = (M: ${T}) => Math.max(1, 2)`).f; const local = hashes(`const f = (Math: ${T}) => Math.max(1, 2)`).f; assert.notEqual(global, local); assert.equal( local, hashes(`const f = (N: ${T}) => N.max(1, 2)`).f, "the local, renamed, is the same code", ); }