mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 06:08:41 +01:00
allow newline before dot for subscript as well, and add to tests
This commit is contained in:
@ -2378,6 +2378,8 @@ static void subscript(Compiler* compiler, bool canAssign)
|
|||||||
finishArgumentList(compiler, &signature);
|
finishArgumentList(compiler, &signature);
|
||||||
consume(compiler, TOKEN_RIGHT_BRACKET, "Expect ']' after arguments.");
|
consume(compiler, TOKEN_RIGHT_BRACKET, "Expect ']' after arguments.");
|
||||||
|
|
||||||
|
allowLineBeforeDot(compiler);
|
||||||
|
|
||||||
if (canAssign && match(compiler, TOKEN_EQ))
|
if (canAssign && match(compiler, TOKEN_EQ))
|
||||||
{
|
{
|
||||||
signature.type = SIG_SUBSCRIPT_SETTER;
|
signature.type = SIG_SUBSCRIPT_SETTER;
|
||||||
|
|||||||
@ -12,6 +12,11 @@ class Test {
|
|||||||
System.print("test2")
|
System.print("test2")
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[index] {
|
||||||
|
System.print("testSubscript")
|
||||||
|
return this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tester {
|
class Tester {
|
||||||
@ -22,36 +27,48 @@ class Tester {
|
|||||||
//test local access
|
//test local access
|
||||||
|
|
||||||
test.
|
test.
|
||||||
test0(). // expect: test0
|
test0(). // expect: test0
|
||||||
test1(). // expect: test1
|
test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
test
|
test
|
||||||
.test0() // expect: test0
|
.test0() // expect: test0
|
||||||
.test1() // expect: test1
|
.test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
test
|
test
|
||||||
.test0() // expect: test0
|
.test0() // expect: test0
|
||||||
.test1(). // expect: test1
|
.test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
|
test[0] // expect: testSubscript
|
||||||
|
.test0() // expect: test0
|
||||||
|
|
||||||
|
test[0]. // expect: testSubscript
|
||||||
|
test0() // expect: test0
|
||||||
|
|
||||||
//test field access
|
//test field access
|
||||||
|
|
||||||
_test.
|
_test.
|
||||||
test0(). // expect: test0
|
test0(). // expect: test0
|
||||||
test1(). // expect: test1
|
test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
_test
|
_test
|
||||||
.test0() // expect: test0
|
.test0() // expect: test0
|
||||||
.test1() // expect: test1
|
.test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
_test
|
_test
|
||||||
.test0(). // expect: test0
|
.test0(). // expect: test0
|
||||||
test1(). // expect: test1
|
test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
|
_test[0] // expect: testSubscript
|
||||||
|
.test0() // expect: test0
|
||||||
|
|
||||||
|
_test[0]. // expect: testSubscript
|
||||||
|
test0() // expect: test0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,50 +82,70 @@ class Tester {
|
|||||||
var external = Tester.new()
|
var external = Tester.new()
|
||||||
|
|
||||||
external.getter.
|
external.getter.
|
||||||
test0(). // expect: test0
|
test0(). // expect: test0
|
||||||
test1(). // expect: test1
|
test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
external.getter
|
external.getter
|
||||||
.test0() // expect: test0
|
.test0() // expect: test0
|
||||||
.test1() // expect: test1
|
.test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
external.getter.
|
external.getter.
|
||||||
test0() // expect: test0
|
test0() // expect: test0
|
||||||
.test1() // expect: test1
|
.test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
|
external.getter[0]. // expect: testSubscript
|
||||||
|
test0() // expect: test0
|
||||||
|
|
||||||
|
external.getter[0] // expect: testSubscript
|
||||||
|
.test0() // expect: test0
|
||||||
|
|
||||||
external.method().
|
external.method().
|
||||||
test0(). // expect: test0
|
test0(). // expect: test0
|
||||||
test1(). // expect: test1
|
test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
external.method()
|
external.method()
|
||||||
.test0() // expect: test0
|
.test0() // expect: test0
|
||||||
.test1() // expect: test1
|
.test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
external.method().
|
external.method().
|
||||||
test0() // expect: test0
|
test0() // expect: test0
|
||||||
.test1(). // expect: test1
|
.test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
|
external.method()[0]. // expect: testSubscript
|
||||||
|
test0() // expect: test0
|
||||||
|
|
||||||
|
external.method()[0] // expect: testSubscript
|
||||||
|
.test0() // expect: test0
|
||||||
|
|
||||||
|
|
||||||
//regular access in module scope
|
//regular access in module scope
|
||||||
|
|
||||||
var other = Test.new()
|
var other = Test.new()
|
||||||
|
|
||||||
other.
|
other.
|
||||||
test0(). // expect: test0
|
test0(). // expect: test0
|
||||||
test1(). // expect: test1
|
test1(). // expect: test1
|
||||||
test2() // expect: test2
|
test2() // expect: test2
|
||||||
|
|
||||||
other
|
other
|
||||||
.test0() // expect: test0
|
.test0() // expect: test0
|
||||||
.test1() // expect: test1
|
.test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
other
|
other
|
||||||
.test0(). // expect: test0
|
.test0(). // expect: test0
|
||||||
test1() // expect: test1
|
test1() // expect: test1
|
||||||
.test2() // expect: test2
|
.test2() // expect: test2
|
||||||
|
|
||||||
|
|
||||||
|
other[0] // expect: testSubscript
|
||||||
|
.test0() // expect: test0
|
||||||
|
|
||||||
|
other[0]. // expect: testSubscript
|
||||||
|
test0() // expect: test0
|
||||||
|
|||||||
Reference in New Issue
Block a user