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

Make parser more resilient to spaces before Catala code block fences #777

Open
denismerigoux opened this issue Jan 28, 2025 · 0 comments · May be fixed by #780
Open

Make parser more resilient to spaces before Catala code block fences #777

denismerigoux opened this issue Jan 28, 2025 · 0 comments · May be fixed by #780
Assignees
Labels
🔧 compiler Issue concerns the compiler ❓ invalid This doesn't seem right

Comments

@denismerigoux
Copy link
Contributor

The following program:

# Title

 ```catala
declaration structure Individual:
  data income content money
  data number_of_children content integer

 declaration scope IncomeTaxComputation:
   input individual content Individual
   internal fixed_percentage content decimal
   output income_tax content money
 ```

 ## Article 1

 The income tax for an individual is defined as a fixed percentage of the
 individual's income over a year.

```catala
 scope IncomeTaxComputation:
   definition income_tax equals
     individual.income * fixed_percentage
```

Returns upon typechecking the following very confusing error:

┌─[ERROR]─
│
│  "IncomeTaxComputation": this scope has not been declared anywhere, is it a typo?
│
├─➤ tutorial.catala_en:31.7-31.27:
│    │
│ 31 │ scope IncomeTaxComputation:
│    │       ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
└─ Title
   └─ Article 2

This is because there is a space before the triple backtick Catala code block fences at the beginning and end of the first code block. The parser then fails to recognize the code block and just does not parse the scope declarations. This is extremely confusing for beginners...

Fixes

  • Either the parser should be made more robust to handle spaces in front of triple backticks to recognize Catala code blocks
  • Or the parser should throw a warning when these spaces are here and it causes it to not parse the code block as Catala code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 compiler Issue concerns the compiler ❓ invalid This doesn't seem right
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants