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

Fix: Reject empty arrays of expressions #224

Merged
merged 1 commit into from Oct 10, 2021

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented Jul 10, 2021

@andythenorth found a bug ;)

switch(FEAT_INDUSTRIES, SELF, test_empty_expression_switch,
    // NML was throwing a not-descriptive parse error with an empty expression
    []) {
    return;
}

triggers "IndexError: pop from empty list" at

self.var_list.pop()
.

But it really should have been rejected way earlier.

@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Jul 10, 2021

Confirmed works as expected with FIRS test case.

Empty array now produces:

nmlc ERROR: "generated/firs.nml", line 185561: Switch-block last parameter 'expression' cannot be an empty array.

Loading

@glx22 glx22 force-pushed the empty_expression_array branch from 1301897 to d2fcd98 Jul 10, 2021
@glx22 glx22 changed the title Fix: Reject empty arrays as switch expressions Fix: Reject empty arrays of expressions Jul 10, 2021
@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Jul 11, 2021

Tested the revised version, works as expected with FIRS test case.

Loading

@LordAro
Copy link
Member

@LordAro LordAro commented Jul 17, 2021

Can we add a regression test?

Loading

@glx22
Copy link
Contributor Author

@glx22 glx22 commented Jul 31, 2021

Quite impossible to add regression test (our regression system doesn't expect failures).

Loading

@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Jul 31, 2021

Yolo?

Loading

@glx22 glx22 merged commit aa922b0 into OpenTTD:master Oct 10, 2021
21 checks passed
Loading
@glx22 glx22 deleted the empty_expression_array branch Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants