Skip to content

template ignores its type, causing codegen errors #10272

@timotheecour

Description

@timotheecour

reduced from a failure I had

template runTest(a: int) =
  echo (a2:a) # error
  # echo (a,) # error
  # echo (a2:a.cint) # works
  # echo a # wokrs

proc main()=
  let SIGSEGV = cint(11)

  # uncomment either, it'll work
  runTest(SIGSEGV)
  runTest(SIGSEGV + 128)

main()

compiling gives:

Error: execution of an external compiler program 'clang -c  -w  -I/Users/timothee/git_clone/nim/Nim/lib -I/Users/timothee/git_clone/nim/timn/bugs/all -o /tmp/nim/nimcache/timn_t0115.c.o /tmp/nim/nimcache/timn_t0115.c' failed with exit code: 1

/tmp/nim/nimcache/timn_t0115.c:184:43: error: passing 'tyTuple_qb5uy5LzAwVQgLdOWmEMWg' (aka 'struct tyTuple_qb5uy5LzAwVQgLdOWmEMWg') to parameter of incompatible type 'tyTuple_UaFDnWb3bcjFoDJyjmi8Ng' (aka 'struct tyTuple_UaFDnWb3bcjFoDJyjmi8Ng')
        T3_[0] = dollar__TsNbE1Gm0cdJ5esJnr9bb1Q(T4_);
                                                 ^~~
/tmp/nim/nimcache/timn_t0115.c:47:105: note: passing argument to parameter 'x' here
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar__TsNbE1Gm0cdJ5esJnr9bb1Q)(tyTuple_UaFDnWb3bcjFoDJyjmi8Ng x);

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