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

BUG: operator error - parenthetical without match fails silently #4

Closed
elrayle opened this issue Sep 5, 2022 · 0 comments · Fixed by #37
Closed

BUG: operator error - parenthetical without match fails silently #4

elrayle opened this issue Sep 5, 2022 · 0 comments · Fixed by #37
Labels
bug Something isn't working

Comments

@elrayle
Copy link
Collaborator

elrayle commented Sep 5, 2022

Description

An open parenthesis in an expression should always have a matching close parenthesis. In the initial implementation in PR #1 , it was noted that a mismatch was silently ignored and swallowed at least the next following token. This leads to an invalid set of tokens instead of an error message.

Expected Behavior

When a matching close parenthesis is not in an expression, an error message should be returned from the scan function.

Proposed New Test

Add the following test (and perhaps other variations) to test for unmatched parentheses to the TestScan function in scan_test.go.

		{"operator error - malformed parenthetical", "(MIT",
		    []token{}, errors.New("open parenthesis does not have a matching close parenthesis")},

Results with current code

expected: *errors.errorString(&errors.errorString{s:"open parenthesis does not have a matching close parenthesis"})
actual  : <nil>(<nil>)
expected: <nil>(<nil>)
actual  : []spdxexp.token{spdxexp.token{role:0x0, value:"("}, spdxexp.token{role:0x3, value:"MIT"}}
@elrayle elrayle added the bug Something isn't working label Oct 25, 2022
elrayle added a commit that referenced this issue Feb 8, 2023
fixes #4

The issue suggested fixing this at the scan level, but scan is just a tokenizer.  Parse knows what is expected syntactically.  The fix was made at the parse level and tests for malformed expressions were added.
elrayle added a commit that referenced this issue Feb 8, 2023
fixes #4

The issue suggested fixing this at the scan level, but scan is just a tokenizer.  Parse knows what is expected syntactically.  The fix was made at the parse level and tests for malformed expressions were added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant