Skip to content

Fix not operator parsing bug#75

Merged
martin-henz merged 2 commits intosource-academy:mainfrom
jonasongg:fix_not_operator_parsing
Feb 9, 2026
Merged

Fix not operator parsing bug#75
martin-henz merged 2 commits intosource-academy:mainfrom
jonasongg:fix_not_operator_parsing

Conversation

@jonasongg
Copy link
Contributor

@jonasongg jonasongg commented Jan 28, 2026

This fixes #74. The bug occurs as the parser assumes previousToken will not be undefined, but it can be if the token is the first in the program. We can also consider enabling noUncheckedIndexedAccess in tsconfig.json to fix similar issues in the future, but it would require quite a bit of effort in fixing compile errors in our codebase at the moment.

The change from switch-case to if-else is not necessary and is merely a style change; the effective change is changing previousToken.type to previousToken?.type.

Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@martin-henz martin-henz merged commit 2b28b2a into source-academy:main Feb 9, 2026
1 check passed
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.

Parser error if the not operator is the first in the program

2 participants