Issue using operators on plain old JS method invocations
dbousamra opened this issue · 3 comments
dbousamra commented
My apologies on the tittle - I struggled to come up with a useful description.
Take this code:
roy> let a = 10
roy> let c = 9
If one tries to perform the following:
roy> a - Math.sqrt(c)
the compiler errors with:
Error: Parse error on line 1: Unexpected '('
at Object.parseError (/Users/domlebo70/Documents/workspace/Roy/roy/lib/parser.js:335:11)
at Object.parse (/Users/domlebo70/Documents/workspace/Roy/roy/lib/parser.js:411:22)
at Interface.nodeRepl (/Users/domlebo70/Documents/workspace/Roy/roy/src/compile.js:619:30)
at Interface.EventEmitter.emit (events.js:96:17)
at Interface._onLine (readline.js:200:10)
at Interface._line (readline.js:518:8)
at Interface._ttyWrite (readline.js:736:14)
at ReadStream.onkeypress (readline.js:97:10)
at ReadStream.EventEmitter.emit (events.js:126:20)
at emitKey (readline.js:1058:12)
No combination of bracket placement seems to get around it.
puffnfresh commented
The deep issue is that it looks like operator parsing is a bit broken.
But anyway, function application doesn't need parentheses. You want to use a - (Math.sqrt c)
.
dbousamra commented
Ah cheers.
rtfeldman commented
To confirm, is a - Math.sqrt(c)
supposed to be valid, except the parser is rejecting it? Or is only a - (Math.sqrt c)
intended to be allowed?