This commit is contained in:
Corey Johnson 2025-10-09 10:44:34 -07:00
parent 66807c02c9
commit 560a946745
2 changed files with 10 additions and 5 deletions

View File

@ -69,6 +69,10 @@ describe('compiler', () => {
test('function call', () => {
expect(`add = fn a b: a + b; add 2 9`).toEvaluateTo(11)
})
test('function call with no args', () => {
expect(`bloop = fn: 'bloop'; bloop`).toEvaluateTo('bloop')
})
})
describe('errors', () => {

View File

@ -72,11 +72,6 @@ export class Compiler {
return [`TRY_LOAD ${value}`]
}
// For now, just treat them all like identifiers
case terms.FunctionCallOrIdentifier: {
return [`TRY_LOAD ${value}`]
}
case terms.BinOp: {
const { left, op, right } = getBinaryParts(node)
const instructions: string[] = []
@ -138,6 +133,12 @@ export class Compiler {
return instructions
}
case terms.FunctionCallOrIdentifier: {
// For now, just treat them all like identifiers, but we might
// need something like TRY_CALL in the future.
return [`TRY_LOAD ${value}`]
}
/*
### Function Calls
Stack order (bottom to top):