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

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.

andythenorth
andythenorth previously approved these changes 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

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

@LordAro
Copy link
Member

LordAro commented Jul 17, 2021

Can we add a regression test?

@glx22
Copy link
Contributor Author

glx22 commented Jul 31, 2021

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

@andythenorth
Copy link
Contributor

Yolo?

@glx22 glx22 merged commit aa922b0 into OpenTTD:master Oct 10, 2021
@glx22 glx22 deleted the empty_expression_array branch October 10, 2021 17:53
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

Successfully merging this pull request may close these issues.

None yet

3 participants