ML icon indicating copy to clipboard operation
ML copied to clipboard

`TypeInference` not working

Open khatchad opened this issue 3 years ago • 4 comments

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 avatar Jan 23 '23 21:01 khatchad

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 avatar Jan 23 '23 21:01 khatchad

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

khatchad avatar Jan 25 '23 15:01 khatchad

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 avatar Jan 25 '23 15:01 khatchad

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

khatchad avatar Feb 13 '24 20:02 khatchad