[
https://issues.apache.org/jira/browse/GROOVY-9440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17053159#comment-17053159
]
Björn Kautler commented on GROOVY-9440:
---------------------------------------
Ah, I got it.
The line information is taken from the parent statement.
In the {{[b]}} example from the {{ListExp}}, in the {{b}} example from the
{{ReturnStatement}}.
If I either replace the explicit return statement by an expression statement
and let Groovy auto-inject the return statement or set the source position on
the return statement manually, the line information is contained in the byte
code and in the stack trace.
I'm not sure whether this is a fix or a work-around though, i. e. if you need
to change something in Groovy due to this.
This is up to you to decide. :)
> Missing line number information in stack trace
> ----------------------------------------------
>
> Key: GROOVY-9440
> URL: https://issues.apache.org/jira/browse/GROOVY-9440
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.8, 3.0.0
> Reporter: Björn Kautler
> Priority: Minor
>
> If you try to run these two features in a Spock spec:
> {code:java}
> def foo() {
> expect: true
> where: a << [b]
> }
> def bar() {
> expect: true
> where: a << b
> } {code}
> You will get a {{MissingPropertyException}} for both of them, which is
> perfectly fine.
> The problem is, that for {{foo}} there is a line number in the stack trace
> while for {{bar}} there is not.
> I checked the byte code, there it is also missing for the {{bar}} case.
> According to [~paulk] the line number information is present in the AST:
> {quote}BlockStatement (no info) -> ReturnStatement (no info) -> Variable
> (with line number info) // b
> BlockStatement (no info) -> ReturnStatement (no info) -> ListExp (correct
> info) -> Variable (correct info) // [b]
> {quote}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)