Bug: int/float overload does not work
- Dominant language
- Python
- Stars
- 16.8k
- Forks
- 603
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 6
Description
```
@tuple
class TestIntFloatOverload:
a: int
b: float
kind: int
IS_INT = 1
IS_FLOAT = 2
def __new__(a: int):
return TestIntFloatOverload(a, 0.0, TestIntFloatOverload.IS_INT)
@overload
def __new__(b: float):
return TestIntFloatOverload(0, b, TestIntFloatOverload.IS_FLOAT)
def __str__(self):
if self.kind == TestIntFloatOverload.IS_INT:
return f"Int: {self.a}"
else:
return f"Float: {self.b}"
def __repr__(self):
return self.__str__()
v1 = TestIntFloatOverload(5)
v2 = TestIntFloatOverload(3.14)
print (f"{v1=}, {v2=}")
```
This prints:
```
v1=Float: 5, v2=Float: 3.14
```
Contributor guide
Research direction
Start by running the provided TestIntFloatOverload snippet and confirm that the integer call selects the float overload. Trace Codon's overload-resolution entry point for constructor calls, then add or update a focused regression test; done means integer arguments select the int overload while float arguments select the float overload.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100