diff --git a/src/compiler/compiler.test.ts b/src/compiler/compiler.test.ts index 08b5586..4a13cad 100644 --- a/src/compiler/compiler.test.ts +++ b/src/compiler/compiler.test.ts @@ -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', () => { diff --git a/src/compiler/compiler.ts b/src/compiler/compiler.ts index 58dcb6d..e304d2c 100644 --- a/src/compiler/compiler.ts +++ b/src/compiler/compiler.ts @@ -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):