wala / ML

Eclipse Public License 2.0
25 stars 17 forks source link

`TypeInference` not working #26

Open khatchad opened 1 year ago

khatchad commented 1 year ago

I am getting a class cast exception when trying to use TypeInference on Python code. The instruction causing the exception is as follows:

s   PythonInvokeInstruction  (id=106)
10 = invokeFunction < PythonLoader, LCodeBody, do()LRoot; > 3,11,2 @5 exception:12

The problem occurs in com.ibm.wala.cast.python.ssa.PythonInvokeInstruction.visit(IVisitor). It tries to cast a TypeInference$TypeOperatorFactory (the type of v below) to a com.ibm.wala.cast.python.ssa.PythonInstructionVisitor:

https://github.com/wala/ML/blob/a8e1d8e54536d382b54c80cdd52f302b0ea06123/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ssa/PythonInvokeInstruction.java#L121

khatchad commented 1 year ago

My guess is that TypeInference.make() should be returning a different type. I see that there is com.ibm.wala.cast.java.analysis.typeInference.AstJavaTypeInference in WALA but no com.ibm.wala.cast.python.analysis.typeInference.AstPythonTypeInference in wala/ML.

khatchad commented 1 year ago

Though, I am unsure what AST has to do with it since it is SSA at this point ...

khatchad commented 1 year ago

There is already a language field in TypeInference. Perhaps then if any subclassing is to be done it would be TypeInference that would be the parent.

khatchad commented 6 months ago

Looks like the new class would inherit from com.ibm.wala.cast.analysis.typeInference.AstTypeInference.