Codegen error with template and implicit dereference #4478

flyx opened this Issue Jul 11, 2016 · 0 comments


None yet

2 participants

flyx commented Jul 11, 2016

When I modify equalsImpl in devel's tables.nim like this:

template equalsImpl() =
  if s.counter == t.counter:
    # different insertion orders mean different 'data' seqs, so we have
    # to use the slow route here:
    for key, val in s:
      if not t.hasKey(key): return false
      if t.getOrDefault(key) != val: return false # << modification here
    return true

And then I try to compile this code:

import tables

  a = {"a": "b"}.newTable()
  b = {"c": "d"}.newTable()

echo a == b

I get the following error:

Error: execution of an external compiler program 'clang -c  -w  -I/Users/flyx/Projects/3rdParty/Nim/lib -o nimcache/stdlib_tables.o nimcache/stdlib_tables.c' failed with exit code: 256

nimcache/stdlib_tables.c:964:47: error: passing 'Table118020 *' (aka 'struct Table118020 *') to parameter of incompatible type 'Table118020' (aka 'struct Table118020'); dereference with *
                                                                        LOC29 = getordefault_118560_30748785(t0, key_118467_30748785);
nimcache/stdlib_tables.c:871:69: note: passing argument to parameter 't0' here
N_NIMCALL(NimStringDesc*, getordefault_118560_30748785)(Table118020 t0, NimStringDesc* key0) {
1 error generated.

I would give an easier example, but I did not succeed in simplifying it. See also #4463 .

@Araq Araq added the Showstopper label Jul 11, 2016
@Araq Araq added a commit that closed this issue Jul 18, 2016
@Araq Araq fixes #4478 d779a9b
@Araq Araq closed this in d779a9b Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment