Files
Nim/compiler
metagn 7a87e7d199 fix compiler crash with uncheckedAssign and range/distinct discrims [backport] (#25585)
On simple code like:

```nim
type Foo = object
  case x: range[0..7]
  of 0..2:
    a: string
  else:
    b: string

var foo = Foo()
{.cast(uncheckedAssign).}:
  foo.x = 5
```

The compiler tries to generate a destructor for the variant fields by
checking if the discrim is equal to the old one, but the type is not
skipped when looking for an `==` operator in system, so any
discriminator with type `range`/`distinct`/etc crashes with:

```
(10, 9) Error: can't find magic equals operator for type kind tyRange
```

This is fixed by just skipping abstract types.
2026-03-07 07:39:57 +01:00
..
2026-01-24 06:07:41 +01:00
2026-01-24 06:07:41 +01:00
2025-12-01 22:59:12 +01:00
2026-02-24 09:39:06 +01:00
2026-02-10 13:21:35 +01:00
2026-02-10 13:21:35 +01:00
2026-02-10 13:21:35 +01:00
2025-12-11 18:22:38 +01:00
2025-12-31 13:33:57 +01:00
2026-02-10 13:21:35 +01:00
2026-01-11 18:39:01 +08:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2026-03-05 12:40:48 +01:00
2025-11-25 12:49:23 +01:00
2024-12-27 19:42:18 +01:00
2025-12-11 18:22:38 +01:00
2025-12-31 13:33:57 +01:00
2026-02-23 13:39:55 +01:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2026-01-09 13:10:04 +01:00
2026-02-10 13:21:35 +01:00
2025-12-29 13:52:22 +01:00
2025-12-11 18:22:38 +01:00
2026-01-07 13:45:26 +01:00
2025-12-11 18:22:38 +01:00
2026-01-24 06:07:41 +01:00
2026-02-10 13:21:35 +01:00
2026-01-24 06:07:41 +01:00
2026-02-10 13:21:35 +01:00
2026-02-10 13:21:35 +01:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2026-02-23 13:39:55 +01:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2026-02-10 13:21:35 +01:00
2025-12-29 13:52:22 +01:00
2025-12-31 13:33:57 +01:00
2026-02-10 13:21:35 +01:00
2025-12-11 18:22:38 +01:00

Nim Compiler

  • This directory contains the Nim compiler written in Nim.
  • Note that this code has been translated from a bootstrapping version written in Pascal.
  • So the code is not a poster child of good Nim code.

See Internals of the Nim Compiler for more information.