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

PriorityQueue doesn't compile on eval target #48

Open
Gama11 opened this issue Dec 21, 2019 · 2 comments
Open

PriorityQueue doesn't compile on eval target #48

Gama11 opened this issue Dec 21, 2019 · 2 comments

Comments

@Gama11
Copy link
Contributor

Gama11 commented Dec 21, 2019

import polygonal.ds.PriorityQueue;

class Main {
	static function main() {}
}
> haxe -main Main -lib polygonal-ds --interp
[...]/PriorityQueue.hx:354: characters 3-13 : error: {+ priority : Int } should be polygonal.ds.PriorityQueue.T
[...]/PriorityQueue.hx:354: characters 3-13 :  have: Array<{+ priority }>
[...]/PriorityQueue.hx:354: characters 3-13 :  want: Array<polygonal.ds.PriorityQueue.T>
[...]/PriorityQueue.hx:536: characters 24-25 : Too many arguments

Tested with Haxe 4.0.5 and polygonal-ds 2.1.1.

@Simn
Copy link
Contributor

Simn commented May 19, 2020

I just came across this as well and got very confused about the Too many arguments error. The problem is that this is supposed to use a static extension from NativeArrayTools, but eval's implementation has its own toArray which then takes priority.

I also don't quite understand where the inference problem comes from and why it only affects eval. Will check this tomorrow.

@Simn
Copy link
Contributor

Simn commented May 20, 2020

I think this has to be worked around here by manually doing NativeArrayTools.toArray(mData, 0, size, []);. The ArrayTools.alloc calls should be type-hinted as var out:Array<T> = ArrayTools.alloc(size);. I'm still not sure why this is target-dependent, but inference can easily go wrong if the Array element type is left open.

I'd send a PR, but I'm getting murdered by whitespace changes...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants