File tree Expand file tree Collapse file tree 3 files changed +43
-26
lines changed
Expand file tree Collapse file tree 3 files changed +43
-26
lines changed Original file line number Diff line number Diff line change @@ -13,17 +13,24 @@ when not defined(nimPreviewSlimSystem):
1313 # # Outplace version of `addFloat`.
1414 result .addFloat (x)
1515
16- proc `$` * (x: int ): string {.raises : [].} =
17- # # Outplace version of `addInt`.
18- result .addInt (x)
19-
20- proc `$` * (x: int64 ): string {.raises : [].} =
21- # # Outplace version of `addInt`.
22- result .addInt (x)
23-
24- proc `$` * (x: uint64 ): string {.raises : [].} =
25- # # Outplace version of `addInt`.
26- addInt (result , x)
16+ template addIntAlias (T: typedesc ) =
17+ proc `$` * (x: T): string {.raises : [].} =
18+ # # Outplace version of `addInt`.
19+ result = " "
20+ result .addInt (x)
21+
22+ # need to declare for bit types as well to not clash with converters:
23+ addIntAlias int
24+ addIntAlias int8
25+ addIntAlias int16
26+ addIntAlias int32
27+ addIntAlias int64
28+
29+ addIntAlias uint
30+ addIntAlias uint8
31+ addIntAlias uint16
32+ addIntAlias uint32
33+ addIntAlias uint64
2734
2835# same as old `ctfeWhitelist` behavior, whether or not this is a good idea.
2936template gen (T) =
Original file line number Diff line number Diff line change @@ -14,21 +14,26 @@ proc rangeBase(T: typedesc): typedesc {.magic: "TypeTrait".}
1414
1515proc repr * (x: NimNode ): string {.magic : " Repr" , noSideEffect .}
1616
17- proc repr * (x: int ): string =
18- # # Same as $x
19- $ x
20-
21- proc repr * (x: int64 ): string =
22- # # Same as $x
23- $ x
24-
25- proc repr * (x: uint64 ): string {.noSideEffect .} =
26- # # Same as $x
27- $ x
28-
29- proc repr * (x: float ): string =
30- # # Same as $x
31- $ x
17+ template dollarAlias (T: typedesc ) =
18+ proc repr * (x: T): string {.noSideEffect .} =
19+ # # Same as $x
20+ $ x
21+
22+ # need to declare for bit types as well to not clash with converters:
23+ dollarAlias int
24+ dollarAlias int8
25+ dollarAlias int16
26+ dollarAlias int32
27+ dollarAlias int64
28+
29+ dollarAlias uint
30+ dollarAlias uint8
31+ dollarAlias uint16
32+ dollarAlias uint32
33+ dollarAlias uint64
34+
35+ dollarAlias float
36+ dollarAlias float32
3237
3338proc repr * (x: bool ): string {.magic : " BoolToStr" , noSideEffect .}
3439 # # repr for a boolean argument. Returns `x`
Original file line number Diff line number Diff line change 1+ # issue #24864
2+
3+ type S = distinct uint16
4+ converter d (field: uint8 | uint16 ): S = discard
5+ discard (repr (0 'u16 ), repr (0 'u8 ))
You can’t perform that action at this time.
0 commit comments