Closed 64kramsystem closed 6 years ago
I got the same.
Now I noticed that token.Then
can only be found once in parser/flow_control_parsing.go and just for case
syntax.
case 9
when 0, 1, 2, 3, 4, 5
0
when 6, 7, 7 + 1, 7 + 2 then
1
when 10, 11, 12
2
end
Then
looks optional and I just wonder if we can drop the keyword then
.
@hachi8833 Yes we can/should, plz help me drop it
Hi I have pushed a PR for this issue. As suggested it drops the support of the then keyword. But I still need an insight on how to test it. It kind of feels awkward to test something that isn't handled by the language.
Anyway now when you use the then
keyword it does something like this.
goby β€ ./goby -i
Goby 0.1.6 π π
Β» if true then
Β» end
#Β» UndefinedMethodError: Undefined Method 'then' for <Instance of: Object>
Congrats for the first PR!
Actually, I created almost the same PR locally π¦
The only difference is a test just to make sure then
is dropped as following:
// vm/evaluation_test.go
func TestUnusedKeywordFail(t *testing.T) {
testsFail := []errorTestCase{
{`
if true then puts 1 end
`, "UndefinedMethodError: Undefined Method 'then' for <Instance of: Object>", 1},
{`
for
`, "UndefinedMethodError: Undefined Method 'for' for <Instance of: Object>", 1},
}
for i, tt := range testsFail {
v := initTestVM()
evaluated := v.testEval(t, tt.input, getFilename())
checkErrorMsg(t, i, evaluated, tt.expected)
v.checkCFP(t, i, 1)
v.checkSP(t, i, 1)
}
}
Any suggestions? @st0012
I think the then
's case is fine. But for
is a keyword, giving the undefined method error might cause confusion.
The test code for for
is unnecessary as you pointed out π
Ok I will add this test to the PR so. thank you guys :smile:
This has been fixed by @amohamedali in #551
Using
if
withthen
causes the interpreter to panic: