whitespace handling bug in if()
MartaBBRM opened this issue · 4 comments
MartaBBRM commented
Dear First Time Contributor,
This ticket evolved. Please scroll through the comments to find out what was discovered.
In case of any questions, feel free to tag me (@czerwinskilukasz1) and type your question.
Cheers,
Łukasz
Core AskQL Contributor
ask { let sumOfSquares = fun (n) {
if (n :lessThanOrEquals (0) ) {
return 0
}
(n*n) + sumOfSquares(n-1)
}
// sum of squares
// 4*4 + 3*3 + 2*2 +1*1
//3*3 + 2*2 + 1*1
//1*1
// 0*0
sumOfSquares(-4)
}
it happened in the cli (AskVM v. 1.2.0) and it was expected to run ;)
The error massage:
SyntaxError: Expected " ", ".", "//", ":", ";", "[", "\n", "\r", "\t", "}", [/], or [\-<>+*\^%=&|] but "{" found.
Location: {
"start": {
"offset": 69,
"line": 2,
"column": 35
},
"end": {
"offset": 70,
"line": 2,
"column": 36
}
}
MartaBBRM commented
czerwinskilukasz1 commented
Thanks.
It seems that the underlying issue is whitespace handling before the trailing bracket in if ()
The minimal example that does not work:
ask {
if(3 :lessThan (4) ) {
return 1
}
}
The culprit is the space in 4) )
.
czerwinskilukasz1 commented
Taken by @199201shubhamsahu
czerwinskilukasz1 commented
(For some reason I cannot add you as an assignee :o, so I listed you in a comment)