Skip to content

Commit

Permalink
(fix) grammar: allow constructors as call arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
xTrayambak committed Jan 14, 2025
1 parent 997aed3 commit f671da7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bali/grammar/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,14 @@ proc parseArguments*(parser: Parser): Option[PositionedArguments] =
of TokenKind.RParen:
metEnd = true
break
of TokenKind.New:
# constructor!
let
call = parser.parseConstructor()
resIdent = "@0_" & $idx

parser.ast.appendToCurrentScope(callAndStoreMut(resIdent, &call))
args.pushIdent(resIdent)
else:
parser.error UnexpectedToken, $token.kind

Expand Down
1 change: 1 addition & 0 deletions tests/data/constructor-as-arg-001.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(new Date())

0 comments on commit f671da7

Please sign in to comment.