Addpattern with mypy - name already defined
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
I was going throught the case studies for `coconut` tutorial and tried using `addpattern`
```python
def factorial(0) = 1
addpattern def factorial(n is int if n > 0) =
"""Compute n! where n is an integer >= 0."""
n * factorial(n - 1)
# Test cases:
-1 |> factorial |> print # MatchError
0.5 |> factorial |> print # MatchError
0 |> factorial |> print # 1
3 |> factorial |> print # 6
```
Now compiling with `coconut fact.coco --mypy` yielded
```
CoconutWarning: missing __init__.coco in package: '...'
Compiling fact.coco ...
Compiled to fact.py .
fact.py:39: error: Name 'factorial' already defined on line 23
Found 1 error in 1 file (checked 1 source file)
Exiting due to MyPy error.
```
The code runs and all but I want to know if this is expected and desired output from `mypy`?
Contributor guide
Research direction
Start by compiling the shown fact.coco example with --mypy and inspect the generated fact.py around the two factorial definitions. Determine whether the duplicate-name diagnostic is expected for addpattern output; done means the behavior is confirmed and documented or the compiler and its relevant coverage are updated if it is incorrect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100