[haXe] Type inferrence problem

Nicolas Cannasse ncannasse at motion-twin.com
Wed Aug 2 08:21:04 CEST 2006


> NC> If you read carefully the error message, you will see that it prints
> NC> "Inconsistent getter for field nodeValue".
> 
> NC> That will give you an tip on what's going wrong : since you access the
> NC> s.iterator whitout knowing its type, it deduces since this is an 
> NC> iterator over objets having a "normal field" nodeValue, while 
> NC> Xml.nodeValue has a getter/setter.
> 
> NC> Hence the error, which is quite lengthy I agree, since it's quite deep
> NC> in the unification phase.
> 
> Ok, I got what's going wrong inside the type inferrence engine here,
> but I still do not think compiler should report error in this case.
> Why does the it deduce that nodeValue is a normal field? It should
> deduce that it is either normal field or a property (maybe assuming
> normal field as a priority), and then solve this 'or' when it
> understands that Xml.nodeValue is a property. I agree this is a
> difficult case for the typer as properties bring some kind of
> undeterminism to automatic inferrence - but it does not seem
> impossible to make the right choice here.

True. This is not a problem impossible to resolve, but it has some 
serious implementation issues, since the code generated when it's a 
property will vary (in that case it will actually be a call to 
Xml.getNodeValue() ). And since the type infered was { nodeValue : 
String } you also have to be sure that it was not used *before* with 
another value. Quite tricky actually.

Nicolas



More information about the Haxe mailing list