Skip to content

Commit

Permalink
feat: throw error if unbound name
Browse files Browse the repository at this point in the history
  • Loading branch information
JothamWong committed Mar 28, 2024
1 parent 1c40fd7 commit 87034d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vm/oogavm-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ type CompileTimeEnvironment = CompileTimeFrame[];
function compileTimeEnvironmentPosition(env: CompileTimeEnvironment, x: string) {
let frameIndex = env.length;
while (frameIndex > 0 && valueIndex(env[--frameIndex], x) === -1) {}
return [frameIndex, valueIndex(env[frameIndex], x)]
let vIndex = valueIndex(env[frameIndex], x);
if (vIndex === -1) {
throw Error("unbound name: " + x);
}
return [frameIndex, vIndex];
}

function valueIndex(frame: CompileTimeFrame, x: string) {
Expand Down

0 comments on commit 87034d5

Please sign in to comment.