Files
Nim/tests/tuples/tconstfield.nim
metagn 4143bb32f7 convert tuple constructors from VM back to original types (#24710)
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.

(cherry picked from commit 49dfc3a0d4)
2025-03-03 14:07:07 +01:00

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.