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 issue with nested binary operators counting as constant typed #567

Merged
merged 3 commits into from
May 20, 2016

Conversation

nathanielc
Copy link
Contributor

@nathanielc nathanielc commented May 19, 2016

Fixes #561

Changes the error detection to compile time if possible.

Also refactors the invalid ... operator errors to be left/right symmetric and correctly report Regex errors.

@nathanielc
Copy link
Contributor Author

@yosiat I refactored a bunch in the eval_binary_node, if you wanted to take a look it would be much appreciated.

se, err := stateful.NewExpression(node)
if err != nil {
t.Fatalf("Failed to compile expression: %v", err)
panic(fmt.Sprintf("Failed to compile expression: %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we do panic here? If one test is failing, we fail here the whole test suite.
By using "Fatal" we fail this test only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it from panic so that you get an ugly stack trace ;) The stack trace makes it easier to figure out which expression didn't compile. Otherwise you have to look through all the expressions in a test.

Also it should only fail when you are changing a test and accidentally create an expression that fails to compile. If its possible for a given expression not to compile then don't use this method and check the error explicitly.

@yosiat
Copy link
Contributor

yosiat commented May 20, 2016

@nathanielc LGTM, except the change in mustCompileExpression which I added a comment.

@nathanielc nathanielc merged commit 3a00e58 into master May 20, 2016
@nathanielc nathanielc deleted the nc-issue#561 branch May 20, 2016 16:04
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.

2 participants