mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
fixes #24609 A tuple may have an incompatible expected type if there is a converter match to it. So the compiler should not error when trying to match the individual elements in the constructor to the elements of the expected tuple type, this will be checked when the tuple is entirely constructed anyway.
19 lines
444 B
Nim
19 lines
444 B
Nim
# issue #24609
|
|
|
|
import std/options
|
|
|
|
type
|
|
Config* = object
|
|
bits*: tuple[r, g, b, a: Option[int32]]
|
|
|
|
# works on 2.0.8
|
|
#
|
|
# results in error on 2.2.0
|
|
# type mismatch: got 'int literal(8)' for '8' but expected 'Option[system.int32]'
|
|
#
|
|
converter toInt32Tuple*(t: tuple[r,g,b,a: int]): tuple[r,g,b,a: Option[int32]] =
|
|
(some(t.r.int32), some(t.g.int32), some(t.b.int32), some(t.a.int32))
|
|
|
|
var cfg: Config
|
|
cfg.bits = (r: 8, g: 8, b: 8, a: 16)
|