Skip to content

Return from addConstant when constant limit is exceeded#1231

Open
cuiweixie wants to merge 1 commit into
wren-lang:mainfrom
cuiweixie:fix/addconstant-return-on-max-constants
Open

Return from addConstant when constant limit is exceeded#1231
cuiweixie wants to merge 1 commit into
wren-lang:mainfrom
cuiweixie:fix/addconstant-return-on-max-constants

Conversation

@cuiweixie
Copy link
Copy Markdown

Summary

In addConstant, when MAX_CONSTANTS is exceeded we call error() but previously did not return. Execution then fell through to return compiler->fn->constants.count - 1, which could emit bytecode with a bogus constant index.

Return -1 after reporting the error (consistent with other failure paths in the compiler).

Testing

python3 util/test.py limit
make -C projects/make.mac

Without returning after the error, execution fell through and returned
compiler->fn->constants.count - 1, which could emit invalid bytecode.
@cuiweixie cuiweixie force-pushed the fix/addconstant-return-on-max-constants branch from 60c7cc9 to df29737 Compare March 27, 2026 06:12
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.

1 participant