Skip to content

nonsensical TypeError from "-X jit -m compile --static" #86

Description

@belm0

good (no options):

$ docker run -v $PWD:/vol -it --rm ghcr.io/facebookincubator/cinder-runtime:cinder-3.8 vol/cinder_typed_prim_bug.py
done 0.57

bad (-X jit -m compile --static):

$ docker run -v $PWD:/vol -it --rm ghcr.io/facebookincubator/cinder-runtime:cinder-3.8 -X jit -m compiler --static vol/cinder_typed_prim_bug.py
Traceback (most recent call last):
  File "/cinder/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/cinder/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/cinder/lib/python3.8/compiler/__main__.py", line 122, in <module>
    exec(codeobj, d, d)
  File "vol/cinder_typed_prim_bug.py", line 15, in __main__
    main()
  File "vol/cinder_typed_prim_bug.py", line 10, in main
    c += foo(.4, .97)
TypeError: unsupported operand type(s) for +=: 'float' and 'function'

The compiler is acting as if the written code were c += foo rather than c += foo(.4, .97).

The problem goes away by removing -X jit, --static, or use of the double primitives.

cinder_typed_prim_bug.py

from __static__ import double

def foo(a: double, b: double) -> double:
    return b - a

def main():
    c = 0.
    c += foo(.4, .97)
    print('done', c)

if __name__ == '__main__':
    main()

seen in cinder-3.8.6c2de94

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions