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
[cpp] Unable to modify Array<T> from inlined method #4187
Comments
Dump:
Cpp:
@hughsando: Your problem or my problem? |
Have not looked at this too closely, but my guess is that this: Array< int
On Thu, Apr 30, 2015 at 3:21 PM, Simon Krajewski notifications@github.com
|
The type of s0->arr should match |
Yes, I think it is - in which case, it looks like it is my problem, and On Thu, Apr 30, 2015 at 3:55 PM, Simon Krajewski notifications@github.com
|
Can we fix this today? I'm not sure I can make a release tomorrow if this is indeed a regression. |
I have been looking at it, but I think the problem is coming from the typing. Looking at the -D dump, it gets Still looking though... |
Actually |
The So the real problem might be : |
In fact, if you call the inline clear function from outside the constructor, it works. |
I think it comes down to arrays being special, and the only way to solve it would be to have an extra level of indirection (virtual functions), which would slow things down.
I think the regression is coming from the tmp variables - I have a feeling the same bug can be shown if explicit tmp variables are used in the old code. |
I suspected as much. I think we can a hack-fix for this in the simplifier for 3.2. I'm having some trouble formalizing the problem though, could you add the relevant case(s) here: https://github.com/HaxeFoundation/haxe/blob/development/analyzer.ml#L218 |
I think it is based on etype, rather than the eexpr. An etype of |
Yes Check a bit below where we check for Void. If I'm understanding it correctly we could just add Array there and maybe restrict it to the cpp target. |
I tried Just using "Array" on cpp would solve the problem - not sure if it would introduce other problems that the original code solved. But maybe this is a good solution on short notice. |
Ok, I have made the change - does not seem like it will cause too many issues. You can close this issue if you are happy with this solution. |
(There was not point checking for KTypeParameter, since I think it has been replaced already) |
Thanks! But well, this is really just a hack. I don't entirely understand why this behavior occurs only when transforming the AST like this. That is, why does it work if I manually store |
Still breaks - see my "Generic" test above - gives "[0]" (correct), but then with the explicit tmp, "[0]" again, which is wrong. |
@Simn do you think a possible solution is to disable inlining of functions that use " Another option would be to not follow the type all the way to a concrete type when inlining, and leave this last step up to the target. This would bring the inlining closer to reproducing exactly what the non-inline version does, rather then being a little bit of "pseudo generic" thing. |
I don't understand why inlining would be relevant here. We can reproduce the same faulty behavior when "inlining by hand":
|
Sure, but you do not get a bug report that starts with "When I inline...." On Mon, May 18, 2015 at 2:33 PM, Simon Krajewski notifications@github.com
|
I guess it depends what kind of a fix you are looking for - quick or good, On Mon, May 18, 2015 at 4:50 PM, Hugh Sanderson gamehaxe@gmail.com wrote:
|
We just made a release so let's go for a good fix. It makes no sense to me to even talk about inlining when the problem can easily be reproduced without inlining. |
Great, I'll think about it some more. On Mon, May 18, 2015 at 5:09 PM, Simon Krajewski notifications@github.com
|
In the setup below, using an inlined method to add to an
Array<T>
doesn't do anything unless<T>
is not an Int/Bool/Float/String (the ones I've tried). It works fine when the generic is removed and the array is given any type or when thepush
method is not inlined. It also works fine if I manually index into the array or if I manually reset the array.I'm testing this with openfl->windows. Works as expected on flash.
Latest master version of all libs, haxe 3.2.0-rc2.
The text was updated successfully, but these errors were encountered: