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

Parser is inaccurate: "100 °C to °F) / 3": is evaluated to "approx. 70.6666666666 °F" #271

Closed
yurivict opened this issue Feb 24, 2024 · 3 comments

Comments

@yurivict
Copy link

yurivict commented Feb 24, 2024

There is no opening brace, so technically this is an invalid expression, and it shouldn't be evaluated like this.

@yurivict yurivict changed the title Parser is inaccurate: Parser is inaccurate: "100 °C to °F) / 3: is evaluated to "approx. 70.6666666666 °F" Feb 24, 2024
@yurivict yurivict changed the title Parser is inaccurate: "100 °C to °F) / 3: is evaluated to "approx. 70.6666666666 °F" Parser is inaccurate: "100 °C to °F) / 3": is evaluated to "approx. 70.6666666666 °F" Feb 24, 2024
@printfn
Copy link
Owner

printfn commented Feb 24, 2024

Unmatched parentheses are an intentional feature, it's really useful to be able to insert ) anywhere and have the parser automatically insert an opening bracket at the start of the input.

@yurivict
Copy link
Author

How does it know where to insert the opening parenthesis? Maybe it isn't intended to be at the beginning?
Generally such guessing would be ambiguous.

@printfn
Copy link
Owner

printfn commented Feb 24, 2024

Yeah, opening parentheses are inserted at the beginning of input, and closing brackets at the end. At some point it might make sense to account for statements (e.g. a = 1+2; a + 1)/2) when inserting parentheses, but I think the usefulness for simple expressions still outweighs the ambiguity.

@printfn printfn closed this as completed Feb 24, 2024
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

No branches or pull requests

2 participants