add isNamedTuple; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) which leaked implementation detail (#10070)
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of leaking implementation detail (Field0: 1, Field1: 2) fixes this: #8670 (comment) /cc @alehander42 @Vindaar @mratsim * Note: isNamedTuple is useful in other places, eg #10010 (comment) * move isNamedTuple to helpers.nim to avoid exposing new symbol to system.nim * remove workaround in tests/vm/tissues.nim failing test now that #10218 was makes it work
This commit is contained in:
parent
bf3a308e86
commit
6ce3949c8a
14 changed files with 113 additions and 23 deletions
|
|
@ -148,3 +148,14 @@ let a = @[1, 2, 3]
|
|||
|
||||
# a.boundedOpenArray(1, 2).foo() # Works
|
||||
echo a.boundedOpenArray(1, 2).len # Internal compiler error
|
||||
|
||||
block: # `$`*[T: tuple|object](x: T)
|
||||
doAssert $(foo1:0, bar1:"a") == """(foo1: 0, bar1: "a")"""
|
||||
doAssert $(foo1:0, ) == """(foo1: 0)"""
|
||||
doAssert $(0, "a") == """(0, "a")"""
|
||||
doAssert $(0, ) == "(0,)"
|
||||
type Foo = object
|
||||
x:int
|
||||
x2:float
|
||||
doAssert $Foo(x:2) == "(x: 2, x2: 0.0)"
|
||||
doAssert $() == "()"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue