Skip to content

Confusing int64 error at cyclic class boundary #146

@bennn

Description

@bennn

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:

## test3

import static

class Board:
def add(self, pos: int64) -> None:
return


## test4

from static import int64
from test3 import Board

class A:
def init(self, b: Board):
self.b: Board = b

def add(self):
    self.b.add(int64(0))

def main():
bb = Board()
A(bb).add()
return

main()


$ [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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions