Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of generics such as Vector<T> or Dictionary<K, V> #528

Closed
jgranick opened this issue Dec 12, 2016 · 5 comments
Closed

Comments

@jgranick
Copy link

jgranick commented Dec 12, 2016

Although the editor handles generics in Array correctly, iterating over custom types incorrectly reports errors

var vector = new Vector<String> ();
vector.push ("Hello");

for (value in vector) {
    
    trace (value.length); // error in IDE
    
}

Flowplay is interested in paying to support the development of this and other issues:

#529
#530
#531

Thanks everyone 😄

@EBatTiVo
Copy link
Contributor

Another sample: http://try.haxe.org/#628a0

class Test {
    static function main() {
		var vector = new Array<String> ();
		vector.push ("Hello");

		for (value in vector) {
	    		trace (value.length); // error in IDE
		}
	}
}

@EricBishton
Copy link
Member

Duplicate of #25, which has some more extensive examples.

@EricBishton
Copy link
Member

After some research into why Array works, but OpenFls's Vector class and Flixel's FlxSprite class don't, I've come to the preliminary conclusion that the error lies with the plugin's inability to deal with in-line conditional compilation directives. (That is: #if, #else, #elseif, and #end, appearing within a code line, rather than on lines by themselves.) Time to revisit this issue, since fixing it will likely fix a host of other issues: see #29, #115, #417, #516.

@EricBishton
Copy link
Member

So, I proved myself wrong. The problem lies in the semantic annotator's (and the type resolver's) inability to track the current type through dynamic variables properly. Rather than extend the semantic annotator, I looked into compiler completion and got that working. See PR #543 for the fix.

Leaving this open, though, because we're still reporting the errors.

@EricBishton
Copy link
Member

Fixed by PRs #616, #603, and partially by #593.

@EricBishton EricBishton changed the title (Bounty) Incorrect handling of generics such as Vector<T> or Dictionary<K, V> Incorrect handling of generics such as Vector<T> or Dictionary<K, V> May 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants