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

RETNIL and RETDEF throwing script errors #566

Closed
Dorbedo opened this issue Dec 20, 2016 · 6 comments · Fixed by #576
Closed

RETNIL and RETDEF throwing script errors #566

Dorbedo opened this issue Dec 20, 2016 · 6 comments · Fixed by #576
Assignees
Labels
Milestone

Comments

@Dorbedo
Copy link
Contributor

Dorbedo commented Dec 20, 2016

Arma 3 Version: 1.66 (stable)
CBA Version: 3.1.2 (stable)

Mods:

  • @CBA_A3

Description:

the new RETNIL and RETDEF macros are throwing errors if the value is not defined (only sheduled environment)

_apple = nil;
_juice = [_apple] param [0]; // throws error

old version:

_cherry = nil;
_juice = If (isNil{_cherry}) then {nil}else{_cherry}; // no error
@Dorbedo
Copy link
Contributor Author

Dorbedo commented Dec 20, 2016

Possible fix ? :

#define RETDEF(VARIABLE,DEFAULT_VALUE) ([VARIABLE,DEFAULT_VALUE] select isNil{VARIABLE})
#define RETNIL(VARIABLE) ([VARIABLE,nil] select isNil{VARIABLE})

@commy2
Copy link
Contributor

commy2 commented Dec 20, 2016

^ would error too

@commy2
Copy link
Contributor

commy2 commented Dec 20, 2016

my proposal:

#define RETDEF(VAR,DEF) (if (isNil QUOTE(VAR)) then [{DEF}, {VAR}])
#define RETNIL(VAR) RETDEF(VAR,nil)

@commy2
Copy link
Contributor

commy2 commented Dec 20, 2016

should also add some unit tests for these, so they are not broken again in future

@654wak654
Copy link
Contributor

654wak654 commented Dec 20, 2016

Why use that syntax commy, the normal if-else syntax doesn't error either.

@commy2
Copy link
Contributor

commy2 commented Dec 20, 2016

Just a command less, doesn't make much difference.

@commy2 commy2 added the Bug label Dec 20, 2016
@commy2 commy2 added this to the 3.2 milestone Dec 20, 2016
@commy2 commy2 self-assigned this Dec 20, 2016
commy2 added a commit that referenced this issue Jan 13, 2017
…#576)

* fix RETNIL and RETDEF throwing script errors, fix #566

* fix comment

* fix function name

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

Successfully merging a pull request may close this issue.

3 participants