Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataclass in file named 9.py fails compilation #1042

Open
johanrex opened this issue Dec 5, 2023 · 0 comments
Open

Dataclass in file named 9.py fails compilation #1042

johanrex opened this issue Dec 5, 2023 · 0 comments

Comments

@johanrex
Copy link

johanrex commented Dec 5, 2023

Bug Report

  • File containing dataclass fails compilation if the module file name is a single number e.g. 9.py.
  • Renaming the file to a9.py makes the compilation succeed.
  • Removing the dataclass related stuff makes the compilation succeed.

To Reproduce

Create a new file named 9.py with this content:

from dataclasses import dataclass


@dataclass
class Map:
    foo: int


print("mypyc")

Compile the file.

mypyc 9.py

Expected Behavior

Successful compilation

Actual Behavior

(aoc_311) PS G:\git\adventofcode\2023> mypyc 9.py
running build_ext
building '9' extension
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt -IC:\Users\johan\miniconda3\envs\aoc_311\include -IC:\Users\johan\miniconda3\envs\aoc_311\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcbuild\__native.c /Fobuild\temp.win-amd64-cpython-311\Release\build\__native.obj /O2 /DEBUG:FASTLINK /wd4102 /wd4101 /wd4146
__native.c
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\getargs.c(342): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\getargsfast.c(449): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\int_ops.c(288): warning C4244: 'function': conversion from 'Py_ssize_t' to 'int', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\int_ops.c(354): warning C4244: '=': conversion from 'Py_ssize_t' to 'digit', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\int_ops.c(696): warning C4244: 'return': conversion from 'long' to 'int16_t', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\int_ops.c(779): warning C4244: 'return': conversion from 'long' to 'uint8_t', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\float_ops.c(21): warning C4244: 'return': conversion from 'Py_ssize_t' to 'double', possible loss of data
C:\Users\johan\miniconda3\envs\aoc_311\Lib\site-packages\mypyc\lib-rt\misc_ops.c(682): warning C4244: 'function': conversion from 'Py_ssize_t' to 'int', possible loss of data
G:\git\adventofcode\2023\build\__native.h(16): error C2059: syntax error: 'bad suffix on number'
G:\git\adventofcode\2023\build\__native.h(16): error C2059: syntax error: 'constant'
build\__native.c(32): error C2059: syntax error: 'bad suffix on number'
build\__native.c(32): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(32): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(32): error C2059: syntax error: 'constant'
build\__native.c(32): error C2059: syntax error: ')'
build\__native.c(41): error C2059: syntax error: 'bad suffix on number'
build\__native.c(41): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(41): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(41): error C2059: syntax error: 'constant'
build\__native.c(41): error C2059: syntax error: ')'
build\__native.c(52): error C2059: syntax error: 'bad suffix on number'
build\__native.c(52): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(52): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(52): error C2059: syntax error: 'constant'
build\__native.c(52): error C2059: syntax error: ')'
build\__native.c(73): error C2059: syntax error: 'bad suffix on number'
build\__native.c(73): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(73): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(73): error C2059: syntax error: 'constant'
build\__native.c(73): error C2059: syntax error: ')'
build\__native.c(75): error C2059: syntax error: 'bad suffix on number'
build\__native.c(75): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(75): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(75): error C2059: syntax error: 'constant'
build\__native.c(75): error C2059: syntax error: ')'
build\__native.c(79): error C2065: 'Map_get_foo': undeclared identifier
build\__native.c(79): warning C4312: 'type cast': conversion from 'int' to 'getter' of greater size
build\__native.c(79): error C2065: 'Map_set_foo': undeclared identifier
build\__native.c(79): warning C4312: 'type cast': conversion from 'int' to 'setter' of greater size
build\__native.c(77): error C2099: initializer is not a constant
build\__native.c(94): error C2065: 'Map_dealloc': undeclared identifier
build\__native.c(94): warning C4312: 'type cast': conversion from 'int' to 'destructor' of greater size
build\__native.c(95): error C2065: 'Map_traverse': undeclared identifier
build\__native.c(95): warning C4312: 'type cast': conversion from 'int' to 'traverseproc' of greater size
build\__native.c(96): error C2065: 'Map_clear': undeclared identifier
build\__native.c(96): warning C4312: 'type cast': conversion from 'int' to 'inquiry' of greater size
build\__native.c(99): error C2059: syntax error: 'bad suffix on number'
build\__native.c(90): error C2099: initializer is not a constant
build\__native.c(100): warning C4047: 'initializing': 'PyBufferProcs *' differs in levels of indirection from 'unsigned long'
build\__native.c(98): warning C4047: 'initializing': 'Py_ssize_t' differs in levels of indirection from 'PyMethodDef *'
build\__native.c(97): warning C4047: 'initializing': 'iternextfunc' differs in levels of indirection from 'PyGetSetDef *'
build\__native.c(93): warning C4047: 'initializing': 'Py_ssize_t' differs in levels of indirection from 'PyObject *(__cdecl *)(PyTypeObject *,PyObject *,PyObject *)'
build\__native.c(107): error C2059: syntax error: 'bad suffix on number'
build\__native.c(107): error C2065: 'self': undeclared identifier
build\__native.c(107): warning C4552: '*': result of expression not used
build\__native.c(108): error C2065: 'self': undeclared identifier
build\__native.c(108): error C2059: syntax error: 'bad suffix on number'
build\__native.c(108): error C2059: syntax error: ')'
build\__native.c(109): error C2065: 'self': undeclared identifier
build\__native.c(109): warning C4047: '==': 'int' differs in levels of indirection from 'void *'
build\__native.c(111): error C2065: 'self': undeclared identifier
build\__native.c(111): error C2223: left of '->vtable' must point to struct/union
build\__native.c(112): error C2065: 'self': undeclared identifier
build\__native.c(112): error C2223: left of '->_foo' must point to struct/union
build\__native.c(113): error C2065: 'self': undeclared identifier
build\__native.c(113): warning C4312: 'type cast': conversion from 'int' to 'PyObject *' of greater size
build\__native.c(130): error C2059: syntax error: 'bad suffix on number'
build\__native.c(130): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(130): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(130): error C2059: syntax error: 'constant'
build\__native.c(130): error C2059: syntax error: ')'
build\__native.c(143): error C2059: syntax error: 'bad suffix on number'
build\__native.c(143): error C2143: syntax error: missing ')' before 'constant'
build\__native.c(143): error C2143: syntax error: missing '{' before 'constant'
build\__native.c(143): error C2059: syntax error: 'constant'
build\__native.c(143): error C2059: syntax error: ')'
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
(aoc_311) PS G:\git\adventofcode\2023>

Your Environment

(aoc_311) PS G:\git\adventofcode\2023> python --version
Python 3.11.5
(aoc_311) PS G:\git\adventofcode\2023> mypy --version
mypy 1.7.1 (compiled: yes)

Let me know if you need any more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant