Confusing int64 error at cyclic class boundary
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the cyclic reproducer in test1.py and test2.py, then compare it with the non-cyclic test3 and test4 cases. Run both examples with static-python and trace how the annotated Board.add call is resolved across the cycle. Done means the cyclic case reports the same correct primitive-argument error as the non-cyclic case.
Written by the indexing model from the issue text.
Description
I have a method that expects an int64, but when I call it from another, special location the error says expected an int.
The other location is across a cyclic dependency: file test1 imports file test2, but the class inside test2 expects an object defined in test1 as an init param:
## test2.py , home of class A
from __future__ import annotations
from __static__ import int64
class A:
def __init__(self, b: Board):
self.b: Board = b
def add(self):
self.b.add(int64(0))
## test1.py , home of class Board
from __static__ import int64
from test2 import A
class Board:
def add(self, pos: int64) -> None:
return
def main():
bb = Board()
A(bb).add()
return
main()
$ [static-python] test1.py
....
File "/vol/static-python-perf/Benchmark/go/advanced/test2.py", line 9, in add
self.b.add(int64(0))
TypeError: add expected 'int' for argument pos, got 'int64'
The correct error is that call arguments cannot be primitive --- right? That's what I see without the cycle:
## test3import static
class Board:
def add(self, pos: int64) -> None:
return
## test4from static import int64
from test3 import Boardclass A:
def init(self, b: Board):
self.b: Board = bdef add(self): self.b.add(int64(0))def main():
bb = Board()
A(bb).add()
returnmain()
$ [static-python] test4.py
....
raise exception
File "test4.py", line 9
self.b.add(int64(0))
^
cinderx.compiler.errors.TypedSyntaxError: Call argument cannot be a primitive
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from facebookincubator/MetaPython
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
facebookincubator/MetaPython#147 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
facebookincubator/MetaPython#145 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
facebookincubator/MetaPython#144 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
facebookincubator/MetaPython#129 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
facebookincubator/MetaPython#116 · 2 comments ·
All issues in facebookincubator/MetaPython
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·