Skip to content

Method calling proc with return value overlapping declared generic type generates invalid C #23765

Open
@tersec

Description

@tersec

Description

type
  X[T, E] = object
    m: T
  B = X[culonglong, cstring]
  S = ref object of RootObj

proc j[T, E](m: X[T, E]): T = discard
proc n(T: typedesc[SomeUnsignedInt]): X[T, cstring] = discard
method call(client: S): uint64 {.base.} =
  discard j(n(uint64))

Nim Version

Nim Compiler Version 2.0.7 [Linux: amd64]
Compiled at 2024-06-27
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 915cd5b28b27285cd46259196ce120a4ea2c84c0
active boot switches: -d:release
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-06-27
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 828cd58d8a0376a5b7a6ad58d73d66617b37629a
active boot switches: -d:release

Current Output

.cache/nim/results_d/@mresults.nim.c:81:83: note: expected ‘tyObject_X__WHq49bCMxAEQUfebzACSwaA’ but argument is of type ‘tyObject_X__P0e5mZLnE3NiPTIl4BhvZA’
   81 | IVATE N_NIMCALL(NU64, j__results_u29)(tyObject_X__WHq49bCMxAEQUfebzACSwaA m_p0) {
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -Inimdevel/lib -Irepro -o .cache/nim/results_d/@mresults.nim.c.o .cache/nim/results_d/@mresults.nim.c' failed with exit code: 1

Expected Output

No invalid generated C

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions