[
https://issues.apache.org/jira/browse/GROOVY-7925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King updated GROOVY-7925:
------------------------------
Description:
The following code runs successfully.
{code}
class Foo {
static void main(String[] args) {
assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
super = true
this = false
assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
}
}
{code}
The attempt to change these 'special' variables is ignored but there should be
some kind of error. I think it makes sense for this to be a compilation error
and it should come late in the compilation phases to allow DSLs to include
'this' or 'super' and transform them into something sensible.
was:
The following code runs successfully.
{code}
class Foo {
static void main(String[] args) {
assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
super = true
this = false
assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
}
}
{code}
The attempt to change these 'special' variables is ignored but there should be
some kind of error.
> 'this' and 'super' as LHS of an assignment
> ------------------------------------------
>
> Key: GROOVY-7925
> URL: https://issues.apache.org/jira/browse/GROOVY-7925
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
>
> The following code runs successfully.
> {code}
> class Foo {
> static void main(String[] args) {
> assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
> super = true
> this = false
> assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
> }
> }
> {code}
> The attempt to change these 'special' variables is ignored but there should
> be some kind of error. I think it makes sense for this to be a compilation
> error and it should come late in the compilation phases to allow DSLs to
> include 'this' or 'super' and transform them into something sensible.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)