mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 06:18:51 +00:00
fixes #24698 The same aim as #24224 but for tuple constructors. The difference here is that the type of a tuple constructor is always going to be valid unlike array constructors which can have `seq` etc types, so we can just generate a conversion again. If the conversion fails, it is ignored similar to #24611, this is to protect against modified typed nodes in macros. Also #24611 was only adapted to `semTupleFieldsConstr` and not `semTuplePositionsConstr`, this is now fixed.
14 lines
278 B
Nim
14 lines
278 B
Nim
# issue #24698
|
|
|
|
type Point = tuple[x, y: int]
|
|
|
|
const Origin: Point = (0, 0)
|
|
|
|
import macros
|
|
|
|
template next(point: Point): Point =
|
|
(point.x + 1, point.y + 1)
|
|
|
|
discard Origin.x # OK: the field is visible.
|
|
discard next(Origin) # Compilation error: the field is not visible.
|