PredefinedTypeNodes not returned for Predefined Types in for statements


The parser defines the type for
int i = 0 ;
as a PredefinedTypeNode.
However, in the statement :
for (int i = 0 ; i < 10 ; i++)

it does not.
It looks like it goes wrong in method Parser.ParseExpressionOrType(). The first statement after the foundType: label constructs a new TypeNode based on the expression found; this expression is the PredefinedTypeNode that we want. I have hacked my local copy to change this statement to:
TypeNode typeNode = expr is PredefinedTypeNode ? (PredefinedTypeNode) expr : new TypeNode(expr);
As far as I can tell, this hasn't broken anything else, but I'm not knowledgeable enough about the parser to be sure. Can anyone tell me if this is a good or bad fix?


debreuil wrote Sep 2, 2009 at 9:19 PM

Hi Paul,

thanks I will check it out. I'm not sure if there are cases where it is better to have all those predefined types wrapped in a type node, hmm, probably not. Anyone else have an opinion?

wrote Feb 14, 2013 at 6:32 PM