a.grace[2:8]: Syntax error: '_' cannot be redeclared because it is already declared as a method on line 1
1: method _ { 1 }
2: method _ { 2 }
-------------^
The same also applies to interface { _; _}
I also note that the following code is not a syntax error, but produces a runtime error:
def _ is public = 1
self._
When run
NoSuchMethod: no method _ on the "a" module (defined at a:1). Did you mean __1?
raised from module initialization at a:2
minigrace: program a exited with code 3.
(writing self.__1 does work)
After some thought, the only uses I can see for _ is as a parameter name (of a method, block, trait, etc.) or as the RHS of an import (import "foo" as _).
I think all other uses should be syntax errors.
You have certainly found some bugs here, but have also raised an interesting language design issue, which we should resolve before expending effort on the way that _ is compiled.
I noticed that the following program is accepted:
But the following is not:
It produces the following error:
The same also applies to
interface { _; _}
I also note that the following code is not a syntax error, but produces a runtime error:
When run
(writing
self.__1
does work)After some thought, the only uses I can see for
_
is as a parameter name (of a method, block, trait, etc.) or as the RHS of an import (import "foo" as _
). I think all other uses should be syntax errors.