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

internal error: no generic body #1500

Closed
dom96 opened this issue Aug 23, 2014 · 11 comments · Fixed by #22580
Closed

internal error: no generic body #1500

dom96 opened this issue Aug 23, 2014 · 11 comments · Fixed by #22580

Comments

@dom96
Copy link
Contributor

dom96 commented Aug 23, 2014

Example

type
  TFtpBase*[SockType] = object
    job: TFTPJob[SockType]

  PFtpBase*[SockType] = ref TFtpBase[SockType]
  TFtpClient* = TFtpBase[string]
  TFTPJob[T] = object

Current Output

Error: internal error: no generic body

Expected Output

This should compile

Workaround

change the order of declarations

type
  TFTPJob[T] = object
  TFtpBase*[SockType] = object
    job: TFTPJob[SockType]

  PFtpBase*[SockType] = ref TFtpBase[SockType]
  TFtpClient = TFtpBase[string]

Additional Information

$ nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-04-26
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: e48f420ab0161d6fc46c72a5a4f0142e77ed9796
active boot switches: -d:release
@dom96 dom96 added this to the 0.9.6 milestone Aug 23, 2014
@dom96
Copy link
Contributor Author

dom96 commented Aug 23, 2014

Workaround is to change the order of the type declarations.

@dom96 dom96 added the Semcheck label Aug 23, 2014
@dom96
Copy link
Contributor Author

dom96 commented Aug 23, 2014

Another example

type
  TFtpClient* = TFtpBase[int]

  PFtpClient* = ref TFTPClient

  PFtpBase*[SockType] = ref TFtpBase[SockType]

  TFtpBase*[SockType] = object
    job: PFTPJob[SockType]

  PFtpJob[T] = ref TFtpJob[T]
  TFTPJob[T] = object


proc ftpClient*(): PFTPClient =
  discard

Edit from Krux02: This compiles in current version of Nim.

@genotrance
Copy link
Contributor

Still crashes with #head

-------- SNIPPET --------
type
  TFtpBase*[SockType] = object
    job: TFTPJob[SockType]

  PFtpBase*[SockType] = ref TFtpBase[SockType]
  TFtpClient* = TFtpBase[string]
  TFTPJob[T] = object
-------------------------

-------- OUTPUT --------
Hint: used config file 'c:\Users\gt\Desktop\dl\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
temp.nim(6, 25) Error: internal error: no generic body
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>
------------------------

-------- NIMTEMP --------
Hint: used config file 'c:\Users\gt\Desktop\dl\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
temp.nim(6, 25) Error: internal error: no generic body
Traceback (most recent call last)
nim.nim(121)             nim
nim.nim(77)              handleCmdLine
main.nim(173)            mainCommand
main.nim(77)             commandCompileToC
modules.nim(242)         compileProject
modules.nim(182)         compileModule
passes.nim(250)          processModule
passes.nim(139)          processTopLevelStmt
sem.nim(576)             myProcess
sem.nim(544)             semStmtAndGenerateGenerics
semstmts.nim(1975)       semStmt
semexprs.nim(797)        semExprNoType
semexprs.nim(2403)       semExpr
semstmts.nim(1151)       semTypeSection
semstmts.nim(1018)       typeSectionRightSidePass
semtypes.nim(1451)       semTypeNode
semtypes.nim(1193)       semGeneric
seminst.nim(217)         instGenericContainer
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(339)      handleGenericInvocation
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(532)      replaceTypeVarsTAux
semtypinst.nim(227)      replaceTypeVarsN
semtypinst.nim(184)      replaceTypeVarsN
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(281)      handleGenericInvocation
msgs.nim(1066)           internalError
msgs.nim(1037)           liMessage
msgs.nim(886)            handleError
msgs.nim(876)            quit
-------------------------

-------- VERSION --------
Nim Compiler Version 0.18.1 [Windows: i386]
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 9d4fd1f1bbc0d8a2327699dd07283260d85a5245
active boot switches: -d:release
-------------------------

@Araq Araq removed this from the 0.9.6 milestone Jun 20, 2018
LemonBoy added a commit to LemonBoy/Nim that referenced this issue Jul 6, 2018
@krux02
Copy link
Contributor

krux02 commented Apr 29, 2019

I updated the issue to conform the current issue template. This is not a crash, because the compiler doesn't crash. It just reports an error even though it should compile. Since the Workaround is trivial, I will set this as low priority for now.

@Araq
Copy link
Member

Araq commented Apr 29, 2019

@krux02 Every "internal error" does count as a crash.

@Araq
Copy link
Member

Araq commented Aug 27, 2023

9 years later and still not fixed...

@bung87
Copy link
Collaborator

bung87 commented Aug 28, 2023

!nim c

{.experimental: "codeReordering".}
type
  TFtpBase*[SockType] = object
    job: TFTPJob[SockType]

  PFtpBase*[SockType] = ref TFtpBase[SockType]
  TFtpClient* = TFtpBase[string]
  TFTPJob[T] = object

@github-actions
Copy link
Contributor

@bung87 (collaborator)

devel 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:16:50
  • Finished 2023-08-28T16:16:51
  • Duration 1 minutes
stable 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:16:52
  • Finished 2023-08-28T16:16:52
  • Duration
2.0.0 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:16:52
  • Finished 2023-08-28T16:16:53
  • Duration
1.6.0 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:16:57
  • Finished 2023-08-28T16:16:57
  • Duration
1.4.0 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:17:00
  • Finished 2023-08-28T16:17:01
  • Duration
1.2.0 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:17:16
  • Finished 2023-08-28T16:17:17
  • Duration
1.0.0 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:17:30
  • Finished 2023-08-28T16:17:30
  • Duration
0.20.2 👍 $\color{green}\textbf{\large OK}$

Output


Stats

  • Started 2023-08-28T16:17:39
  • Finished 2023-08-28T16:17:40
  • Duration
Stats
  • GCC 11.4.0
  • LibC 2.35
  • Valgrind 3.18.1
  • NodeJS 17.1
  • Linux 5.15.0
  • Created 2023-08-28T16:15:53Z
  • Comments 7
  • Commands nim c --run -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 53 minutes bisecting 8 commits at 0 commits per second.

@bung87
Copy link
Collaborator

bung87 commented Aug 28, 2023

is there's any side effect not to enable codeReordering by default ?

@juancarlospaco
Copy link
Collaborator

codeReordering is not macro aware AFAIU.

@jmgomez
Copy link
Collaborator

jmgomez commented Aug 28, 2023

The code block should work without codeReordering though.
Didnt look at the code but it shouldnt be too different to the fix we did for inheriting types or sets within the type section block

jmgomez added a commit to jmgomez/Nim that referenced this issue Aug 28, 2023
Araq pushed a commit that referenced this issue Sep 1, 2023
* fixes internal error: no generic body fixes #1500

* adds guard

* adds guard

* removes unnecessary test

* refactor: extracts containsGenericInvocationWithForward
narimiran pushed a commit that referenced this issue Apr 17, 2024
* fixes internal error: no generic body fixes #1500

* adds guard

* adds guard

* removes unnecessary test

* refactor: extracts containsGenericInvocationWithForward

(cherry picked from commit 0c6e138)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants