Community
Participate
Working Groups
Build Identifier: I20110613-1736 The following code works as expected: print(if (true) {"true"} else {"false"}) And is generated as: public static void main(String[] args) { String _xifexpression = null; if (true) { _xifexpression = "true"; } else { _xifexpression = "false"; } InputOutput.<String>print(_xifexpression); } but, the following code doesn't work: print(if (true) {return "true"} else {"false"}) as it generate this code: public static void main(String[] args) { String _xifexpression = null; if (true) { return "true"; } else { _xifexpression = "false"; } InputOutput.<String>print(_xifexpression); } Reproducible: Always Steps to Reproduce: print(if (true) {return "true"} else {"false"})
Just to be clear
I would expect an error marker on the return expression in a context that expects void as the return type. Daniel, does that meet your expectation, too?
Agree if the context is void, but that's not clear for me since Daniel only posted the expression not the context. But it looks like he's referring to PureXbase, which should expect void but doesn't. So this might be a bug in PureXbase.
Yes, it was in the PureXBase. I typed the expression in a .xbase file in the XBase demo project, that comes with XText.
Rather than expecting void in the type provider I think we should generate into a method with the return type Object. That way people will be able to play around with return expressions as well.
pushed to master
Closing all bugs that were set to RESOLVED before Neon.0