martin-pabst / Online-IDE-new-compiler

Online-IDE with new compiler
GNU General Public License v3.0
1 stars 0 forks source link

runtime error when comparing Double object #12

Closed fjf2002 closed 1 month ago

fjf2002 commented 1 month ago
Object o = Double.valueOf(42);
println(o == 42)

... results in run time failure:

SystemException in thread main thread: System exception: TypeError: Cannot convert object to primitive value
at $MainClass86.$main (File new file 0.java: 5)

... whereas the following code runs successfully:

Double o = Double.valueOf(42);
println(o == 42)
martin-pabst commented 1 month ago

Thank you! Compiler now issues compile time error: "Operator == is not defined for operands of type Object and int."