dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
6 stars 0 forks source link

When adding null to a string it sometimes throws a compile-time exception #221

Closed dplassgit closed 1 year ago

dplassgit commented 1 year ago
Exception in thread "main" java.lang.NullPointerException
        at com.plasstech.lang.d2.optimize.ArithmeticOptimizer.optimizeAdd(ArithmeticOptimizer.java:530)
        at com.plasstech.lang.d2.optimize.ArithmeticOptimizer.visit(ArithmeticOptimizer.java:145)
        at com.plasstech.lang.d2.codegen.il.BinOp.accept(BinOp.java:46)
        at com.plasstech.lang.d2.optimize.LineOptimizer.optimize(LineOptimizer.java:56)
        at com.plasstech.lang.d2.optimize.ILOptimizer.optimize(ILOptimizer.java:76)
        at com.plasstech.lang.d2.optimize.ILOptimizer.execute(ILOptimizer.java:57)
        at com.plasstech.lang.d2.D2Compiler.main(D2Compiler.java:76)
dplassgit commented 1 year ago

And also someimtes it adds the string "null" to the string.

dplassgit commented 1 year ago

And with no optimization it throws a different exception

Exception in thread "main" java.lang.NullPointerException
        at com.plasstech.lang.d2.codegen.StringCodeGenerator.generateStringLength(StringCodeGenerator.java:494)
        at com.plasstech.lang.d2.codegen.StringCodeGenerator.generateStringAdd(StringCodeGenerator.java:400)
        at com.plasstech.lang.d2.codegen.NasmCodeGenerator.visit(NasmCodeGenerator.java:315)
        at com.plasstech.lang.d2.codegen.il.BinOp.accept(BinOp.java:46)
        at com.plasstech.lang.d2.codegen.NasmCodeGenerator.execute(NasmCodeGenerator.java:158)
        at com.plasstech.lang.d2.D2Compiler.main(D2Compiler.java:86)