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

Impossible to write tuple (0,0) #724

Open
denismerigoux opened this issue Oct 15, 2024 · 3 comments
Open

Impossible to write tuple (0,0) #724

denismerigoux opened this issue Oct 15, 2024 · 3 comments
Assignees
Labels
❌ bug Something isn't working 🔧 compiler Issue concerns the compiler

Comments

@denismerigoux
Copy link
Contributor

Writing this tuple currently yields the error:

┌─[ERROR (2/2)]─
│
│  Syntax error at "0":
│  » expected binary operator
│  Those are valid at this point: ".", ">", "=", ")", "+", "-", "*", "/", "++", "!=", ">=", "<=", "jour", "mois", "an", "mais en remplaçant", "ou bien", "ou", "et",
│  "pour", "sous forme", "contient", "de"
│
├─➤ src/1-filtrage.catala_fr:353.17-353.18:
│     │
│ 353 │       puis (0,  0)
│     │                 ‾
│
│ Maybe you wanted to write: ".", ">", "=", ")", "+", "-", "*" or "/"?

I can get around by let binding 0 to a variable but not very elegant.

@AltGr
Copy link
Contributor

AltGr commented Oct 17, 2024

You can work around it by writing (0 , 0), otherwise yes, the first element is parsed as the decimal 0.0
Possible solutions:

  • require the space above, although that's ugly
  • require decimals to have at least a digit after the decimal separator. Not sure it's a good solution here, but that might be a good idea for the readability of the code anyways (e.g. always require the user to write 12,0 rather than 12, for the decimal twelve -- that's what I prefer to do in examples anyway). It remains fragile because (12,0) and (12, 0) then are valid syntax for completely different things (a decimal singleton a pair of integers, respectively)
  • change the separator in tuples to ;, making them closer in appearance to lists, but avoiding the clash with the french decimal separator

@denismerigoux
Copy link
Contributor Author

I would be in favor of keeping the current behavior as is but throwing out a warning in the parser if it detects in the French language an instance of LEFTPARENT NUMBER COMMA NUMBER RIGHTPAREN suggesting the user that they're mistaking the tuple for the decimal and showing the workarounds mentionned aboved. Do you think it's doable @AltGr?

@denismerigoux
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❌ bug Something isn't working 🔧 compiler Issue concerns the compiler
Projects
Status: Todo
Development

No branches or pull requests

2 participants