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
choose() function [u524]/Variadic varargs #214
Comments
I think it did work before, but I also noticed that it is broken now. Works with only 2 or so arguments. |
I had a similar issue with mean when josh switched out the C parser. Probably needs the same fix. |
The bug occurs only when you try using a variable, not a literal, as an argument for the |
I have done some regression testing on this issue. Create event: a = 1;
b = 2;
c = 3; Step event: if (keyboard_check_released(vk_space)) {
show_message(choose(a,b,c));
show_message(choose(1,2,3));
show_choose_message();
} show_choose_message() script: show_message(choose(a,b,c));
show_message(choose(1,2,3));
|
It's not only choose, but min, max, median and so on. I have reported this before, most recently here: http://enigma-dev.org/forums/index.php?topic=1860.0 |
@sorlok Do you think you could possibly offer some insight into how this functionality broke? I'm just wondering since you seem really good about offering a new perspective on old issues. |
Well, I'm not sure how it broke, but I think @TheExDeus describes the issue perfectly. The parser doesn't tag variables inside functions correctly. Which means a grueling parser debug to fix this bug. |
Hmmm, the problem is I would try to fix it but I don't even know where to start really. It's a part that I am unfamiliar with, but I guarantee it's a simple fix. @JoshDreamland Should offer some clues for where to look. |
I doubt this "broke". I think it never worked. I made a topic about this issue in April, but I mentioned it before last year or even a year before that. So as far as I'm aware this was never fixed/implemented. Basically you need to check variables inside the vararg functions and see if instances has them as locals or if you need to create a temporary one. I guess the problem here is the vararg's (functions with variable number of arguments) which are not properly handled in current parser. |
Another workaround discovered in #914 is the following: var yolo,swag;
swag = self.swag; |
I should add that this issue was also a duplicate of #5 which was already a known parser bug. |
I should mention too that I think the Wiki article about varargs is outdated. And just plain |
(Posted by on the ENIGMA forums)
The choose() gml function isn't implemented in enigma properly. There needs to be a way to have any number of arguments on a range from 2 to the argument limit (which I think in GM is 16?). I'm trying to port a game made by a friend of mine to Linux but can't because of the errors related to his use of the choose() function.
The text was updated successfully, but these errors were encountered: