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

Distinct procs fail to compile #11600

massung opened this issue Jun 26, 2019 · 0 comments


Copy link

commented Jun 26, 2019

Using a distinct type alias for a proc type causes a compile failure in C:

  Foo = distinct proc()

proc test() =
  echo "Hello, world!"

let foo = test.Foo


Output compiling with nim c:

        ... Error: execution of an external compiler program 'gcc.exe -c  -w -mno-ms-bitfields  -IC:\nim\lib -IC:\Users\Jeff\Projects\nim\test\src -o C:\Users\Jeff\nimcache\test_d\test.nim.c.o C:\Users\Jeff\nimcache\test_d\test.nim.c' failed with exit code: 1
        ... C:\Users\Jeff\nimcache\test_d\test.nim.c: In function 'NimMainModule':
        ... C:\Users\Jeff\nimcache\test_d\test.nim.c:434:2: error: called object 'foo_ZfOeS0yQniRMc1h11zL9bIg' is not a function or function pointer
        ...   foo_ZfOeS0yQniRMc1h11zL9bIg();
        ...   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
        ... C:\Users\Jeff\nimcache\test_d\test.nim.c:240:31: note: declared here
        ...  tyProc_IIomJ6ptE6vfJ5zRbATgkQ foo_ZfOeS0yQniRMc1h11zL9bIg;
        ...                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Simply removing the distinct keyword allows it to compile just fine.

$ nim -v
Nim Compiler Version 0.20.0 [Windows: amd64]
Compiled at 2019-06-06
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: e7471cebae2a404f3e4239f199f5a0c422484aac
active boot switches: -d:release

@Araq Araq closed this in b6fb47d Jun 26, 2019

Araq added a commit that referenced this issue Jun 26, 2019

narimiran added a commit that referenced this issue Jun 27, 2019

fixes #11600
(cherry picked from commit b6fb47d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.