When working with a simple Haxe-React app, I get the following compile time errors:
genes/0,4,1/src/genes/es/ModuleEmitter.hx:248: characters 18-28 : Uncaught exception field access on null
genes/0,4,1/src/genes/es/ModuleEmitter.hx:37: characters 11-49 : Called from here
genes/0,4,1/src/genes/Generator.hx:114: characters 5-48 : Called from here
It happens as soon as I'm importing an React component with state or props. (I don't need to actually use the component, importing it is enought to cause the error).
A solution seems to be to add a null check tofield.expr in ModuleEmitter.hx, before the switch in line 248:
for (field in fields)
switch field.kind {
case Constructor | Method #if (haxe_ver >= 4.2) if (!field.isAbstract) #end:
if (field.expr != null) // <--- Added this
switch field.expr.expr {
case TFunction(f) if (export || !field.isStatic):
writeNewline();
Here's the react component that I'm referencing, if that's of interest:
import react.ReactComponent;
import react.ReactMacro.jsx;
using Std;
typedef AppProps = {test:Int}
typedef AppState = {name:String}
class App extends ReactComponentOf<AppProps, AppState> {
public function new(props:AppProps) {
super(props);
this.state = {name: 'Bob'};
}
override function render():ReactElement {
return jsx('<>
<p>props: ${this.props.string()}</p>
<p>state: ${this.state.string()}</p>
</>');
}
}
Hello again!
When working with a simple Haxe-React app, I get the following compile time errors:
It happens as soon as I'm importing an React component with state or props. (I don't need to actually use the component, importing it is enought to cause the error).
A solution seems to be to add a null check to
field.expr
in ModuleEmitter.hx, before the switch in line 248:Here's the react component that I'm referencing, if that's of interest: