compile spacey function calls too

This commit is contained in:
Chris Wanstrath 2025-11-10 07:09:50 -08:00
parent 12370361c4
commit dcf94296fa
2 changed files with 22 additions and 1 deletions

View File

@ -482,6 +482,7 @@ export class Compiler {
PUSH 1 ; Named count
CALL
*/
case terms.FunctionCallWithNewlines:
case terms.FunctionCall: {
const { identifierNode, namedArgs, positionalArgs } = getFunctionCallParts(node, input)
const instructions: ProgramItem[] = []
@ -863,7 +864,7 @@ export class Compiler {
default:
throw new CompilerError(
`Compiler doesn't know how to handle a "${node.type.name}" node.`,
`Compiler doesn't know how to handle a "${node.type.name}" (${node.type.id}) node.`,
node.from,
node.to
)

View File

@ -440,6 +440,26 @@ describe('Parentheses', () => {
PositionalArg
Identifier arg3`)
})
test('function call with mulitline identifiers starting separate lines in parens', () => {
expect(`(
echo
arg1
arg2
arg3
)`).toMatchTree(`
ParenExpr
FunctionCall
Identifier echo
PositionalArg
Identifier arg1
PositionalArg
Identifier arg2
PositionalArg
Identifier arg3`)
})
})
describe('Number literals', () => {