Skip to content

Invalid C code generation with seq[array[...]] #25475

@tersec

Description

@tersec

Nim Version

Any of

Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2026-02-03
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release
Nim Compiler Version 2.2.6 [Linux: amd64]
Compiled at 2026-02-03
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: ab00c56904e3126ad826bb520d243513a139436a
active boot switches: -d:release
Nim Compiler Version 2.2.7 [Linux: amd64]
Compiled at 2026-02-03
Copyright (c) 2006-2026 by Andreas Rumpf

git hash: d48fc130c137f22d2e9d3c35eba215ed7684f186
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2026-02-03
Copyright (c) 2006-2026 by Andreas Rumpf

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

with either of

gcc (Debian 15.2.0-12) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

or

Debian clang version 21.1.8 (2)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin

Description

type N = object
  b: seq[array[1'u, int]]
discard N(b: @[[0]])

Admittedly, it's not clear this should compile: one array has size 1'u while the other has size 1. But a C compilation error shouldn't happen regardless. It's also notable that many variations of this code do seem to treat array[1, int] and array[1'u, int] as at least implicitly convertible types.

Current Output

Hint: used config file '/tmp/nim23/config/nim.cfg' [Conf]
Hint: used config file '/tmp/nim23/config/config.nims' [Conf]
......................................................................
CC: system/exceptions.nim
CC: std/private/digitsutils.nim
CC: system/dollars.nim
CC: system.nim
CC: u.nim
/tmp/tmp.pgKbRZ2xbT/@mu.nim.c: In function ‘NimMainModule’:
/tmp/tmp.pgKbRZ2xbT/@mu.nim.c:143:9: error: incompatible types when assigning to type ‘tySequence__PaPqxATneMvaJgZdR29cujw’ from type ‘tySequence__iR7FNQIicfV9cQXx6NvdXYw’
  143 | T1_.b = colontmpD_;
      |         ^~~~~~~~~~
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -fno-strict-aliasing -pthread   -I/tmp/nim23/lib -I/tmp -o /tmp/tmp.pgKbRZ2xbT/@mu.nim.c.o /tmp/tmp.pgKbRZ2xbT/@mu.nim.c' failed with exit code: 1

Expected Output

No C compilation error

Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions