[ https://issues.apache.org/jira/browse/SYSTEMML-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15951362#comment-15951362 ]
Mike Dusenberry commented on SYSTEMML-259: ------------------------------------------ [~deron] Unfortunately, I think we need to look further at this. I tried updating the {{nn}} library to remove the unneeded left-hand variables for test functions with no returns, and I experienced a null pointer issue. I boiled it down to the following small example. {code} func = function(int a) { print(a) } func(3) {code} This snippet works as expected, which was initially surprising given that my real example in the {{nn}} library was failing. I took a look at the explain, and realized that this function was just being inlined, and thus was working just fine. {code} # Memory Budget local/remote = 5496MB/140MB/140MB # Degree of Parallelism (vcores) local/remote = 48/1/1 PROGRAM ( size CP/MR = 0/0 ) --MAIN PROGRAM ----GENERIC (lines 6-6) [recompile=false] ------CP print 3.SCALAR.INT.true _Var0.SCALAR.STRING ------CP rmvar _Var0 3 {code} Adding a graph cut to force the compiler to keep the function invokes the issue. {code} func = function(int a) { if(1==1){} # cut! print(a) } func(3) {code} {code} java.lang.NullPointerException at org.apache.sysml.parser.StatementBlock.validate(StatementBlock.java:599) at org.apache.sysml.parser.DMLTranslator.validateParseTree(DMLTranslator.java:141) at org.apache.sysml.api.DMLScript.execute(DMLScript.java:589) at org.apache.sysml.api.DMLScript.executeScript(DMLScript.java:351) at org.apache.sysml.api.DMLScript.main(DMLScript.java:212) Exception in thread "main" org.apache.sysml.api.DMLException: java.lang.NullPointerException at org.apache.sysml.api.DMLScript.executeScript(DMLScript.java:365) at org.apache.sysml.api.DMLScript.main(DMLScript.java:212) Caused by: java.lang.NullPointerException at org.apache.sysml.parser.StatementBlock.validate(StatementBlock.java:599) at org.apache.sysml.parser.DMLTranslator.validateParseTree(DMLTranslator.java:141) at org.apache.sysml.api.DMLScript.execute(DMLScript.java:589) at org.apache.sysml.api.DMLScript.executeScript(DMLScript.java:351) ... 1 more Failed to run SystemML. Exit code: 1 {code} Adding the dummy return variable works. {code} func = function(int a) { if(1==1){} print(a) } tmp = func(3) {code} {code} PROGRAM ( size CP/MR = 0/0 ) --FUNCTIONS ----FUNCTION CALL GRAPH ------MAIN PROGRAM --------.defaultNS::func ----FUNCTION .defaultNS::func [recompile=false] ------GENERIC (lines 3-3) [recompile=false] --------CP print a.SCALAR.INT.false _Var1.SCALAR.STRING --------CP rmvar _Var1 --------CP rmvar a --MAIN PROGRAM ----GENERIC (lines 6-6) [recompile=false] ------CP extfunct .defaultNS func 1 1 3.SCALAR.INT.true tmp 3 {code} Thoughts? > If no return type specified, DML/PyDML function calls require an lvalue > ----------------------------------------------------------------------- > > Key: SYSTEMML-259 > URL: https://issues.apache.org/jira/browse/SYSTEMML-259 > Project: SystemML > Issue Type: Improvement > Components: APIs > Reporter: Deron Eriksson > Assignee: Deron Eriksson > Priority: Minor > Fix For: SystemML 1.0 > > > If a function is defined in DML or PyDML with no return type, and then this > function is called, it requires an lvalue variable to be assigned the value > returned from the function, even though no value is returned from the > function. > DML Example (assigning to z is required): > {code}hello = function() { > print('hi') > } > z = hello(){code} > PyDML Example (assigning to z is required): > {code}def hello(): > print('hi') > z = hello(){code} > DML Example (error: "function call needs to have lvalue (Quickfix: change it > to 'tmpVar = hello(...)')"): > {code}hello = function() { > print('hi') > } > hello(){code} > PyDML Example(error: "function call needs to have lvalue (Quickfix: change it > to 'tmpVar = hello(...)')"): > {code}def hello(): > print('hi') > hello(){code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)