apache / royale-compiler

Apache Royale Compiler
https://royale.apache.org/
Apache License 2.0
98 stars 50 forks source link

Compile error when passing function generator to labelField #216

Closed estanglerbm closed 1 year ago

estanglerbm commented 2 years ago

Attached example (labelField="bindItem(...)") throws this error:

c:\somewhere\TestLabelItemBind.mxml line 16 column 31 Error: Internal error in ASBlockWalker subsystem, when generating code for: c:\somewhere\TestLabelItemBind.mxml line 16 column 31: java.lang.NullPointerException
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitInstance(MXMLRoyaleEmitter.java:2483)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitInstance(MXMLBlockWalker.java:265)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:165)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitPropertySpecifier(MXMLRoyaleEmitter.java:3091)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitPropertySpecifier(MXMLBlockWalker.java:273)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:111)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitInstance(MXMLRoyaleEmitter.java:2541)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitInstance(MXMLBlockWalker.java:265)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:101)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitArray(MXMLRoyaleEmitter.java:3181)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitArray(MXMLBlockWalker.java:305)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:77)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitPropertySpecifier(MXMLRoyaleEmitter.java:3091)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitPropertySpecifier(MXMLBlockWalker.java:273)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:111)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitDocument(MXMLRoyaleEmitter.java:877)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleBlockWalker.visitDocument(MXMLRoyaleBlockWalker.java:69)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:89)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleBlockWalker.visitFile(MXMLRoyaleBlockWalker.java:61)
        at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:95)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:156)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitCompilationUnit(MXMLBlockWalker.java:187)
        at org.apache.royale.compiler.internal.codegen.mxml.MXMLWriter.writeTo(MXMLWriter.java:69)
        at org.apache.royale.compiler.clients.MXMLJSCRoyale.writeCompilationUnit(MXMLJSCRoyale.java:538)
        at org.apache.royale.compiler.clients.MXMLJSCRoyale.compile(MXMLJSCRoyale.java:452)
        at org.apache.royale.compiler.clients.MXMLJSCRoyale._mainNoExit(MXMLJSCRoyale.java:273)
        at org.apache.royale.compiler.clients.MXMLJSCRoyale.mainNoExit(MXMLJSCRoyale.java:230)
        at org.apache.royale.compiler.clients.MXMLJSC._mainNoExit(MXMLJSC.java:346)
        at org.apache.royale.compiler.clients.MXMLJSC.mainNoExit(MXMLJSC.java:281)
        at org.apache.royale.compiler.clients.MXMLJSC.staticMainNoExit(MXMLJSC.java:241)
        at org.apache.royale.compiler.clients.MXMLJSC.main(MXMLJSC.java:220)

Works fine in Flex.

TestLabelItemBind.mxml.txt

joshtynjala commented 2 years ago

Some investigation:

It seems to be failing on this line, so I guess fdef is null:

String fnName = fdef.getBaseName();

Interestingly, fnName doesn't actually seem to be used, so we can probably just remove it entirely.