Allow empty argument list methods.
- Compile them as calls and definitions. - Use them for call(), clear(), run(), try(), and yield(). - Update the docs.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class Foo {
|
||||
method { 0 }
|
||||
method { "getter" }
|
||||
method() { "no args" }
|
||||
method(a) { a }
|
||||
method(a, b) { a + b }
|
||||
method(a, b, c) { a + b + c }
|
||||
@@ -19,7 +20,8 @@ class Foo {
|
||||
}
|
||||
|
||||
var foo = new Foo
|
||||
IO.print(foo.method) // expect: 0
|
||||
IO.print(foo.method) // expect: getter
|
||||
IO.print(foo.method()) // expect: no args
|
||||
IO.print(foo.method(1)) // expect: 1
|
||||
IO.print(foo.method(1, 2)) // expect: 3
|
||||
IO.print(foo.method(1, 2, 3)) // expect: 6
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
var list = [1, 2]
|
||||
list[] // expect error
|
||||
"don't actually want error here, but cascades from above" // expect error
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
[] { "empty" } // expect error
|
||||
}
|
||||
Reference in New Issue
Block a user