facebookincubator / cinder

Cinder is Meta's internal performance-oriented production version of CPython.
https://trycinder.com
Other
3.43k stars 122 forks source link

"TypeError: an integer is required" when calling function returning double #26

Closed belm0 closed 2 years ago

belm0 commented 3 years ago

seen as of cinder 5bd8c57 (and it occurs prior to that commit)

from __static__ import double

def test() -> double:
    return double(.5)

test()
$ python -m compiler --static foo.py
TypeError: an integer is required

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/compiler/__main__.py", line 111, in <module>
    exec(codeobj)
  File "/.../foo.py", line 6, in __main__
    test()
SystemError: PyEval_EvalFrameEx returned a result with an error set

(Same error even when test() is not called from module scope.)

czardoz commented 3 years ago

Ah right, returning primitive doubles is not yet supported. I'll make this a compiler reported error, so we don't crash.

belm0 commented 3 years ago

Our application is heavily numeric, so returning primitive doubles will be key to getting performance out of static modules 🙏

czardoz commented 2 years ago

@belm0 This should be fixed since f244f2cd93598c564a4219f7c2b86ac493f2ba7e

Can you try it out and let me know if you still see an issue? :)

czardoz commented 2 years ago

Closing for now, will re-open if necessary