-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore match errors to expected types of tuple constructor elements (#…
…24611) 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.
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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) |