Bug 509956 - safe navigation expression in while not using the latest result
Summary: safe navigation expression in while not using the latest result
Status: UNCONFIRMED
Alias: None
Product: Xtend
Classification: Tools
Component: Errors (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-05 02:38 EST by paul lu CLA
Modified: 2017-01-31 04:59 EST (History)
1 user (show)

See Also:


Attachments
xtend code (549 bytes, application/octet-stream)
2017-01-05 02:40 EST, paul lu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description paul lu CLA 2017-01-05 02:38:44 EST
while(a?.b?.c != null){
           
        }
is translated to : 
    B _b = null;
    if (a!=null) {
      _b=a.getB();
    }
    C _c = null;
    if (_b!=null) {
      _c=_b.getC();
    }
    boolean _notEquals = (!Objects.equal(_c, null));
    boolean _while = _notEquals;
    while (_while) {
      Integer _limit = a.getLimit();
      InputOutput.<Integer>println(_limit);
      C _c_1 = null;

      //error: a?.b is not evaluated again 

      if (_b!=null) {
        _c_1=_b.getC();
      }
      boolean _notEquals_1 = (!Objects.equal(_c_1, null));
      _while = _notEquals_1;
    }
Comment 1 paul lu CLA 2017-01-05 02:40:17 EST
Created attachment 266132 [details]
xtend code
Comment 2 Christian Dietrich CLA 2017-01-31 04:59:10 EST
see https://github.com/eclipse/xtext-xtend/issues/144 as well