File tree 3 files changed +43
-29
lines changed
3 files changed +43
-29
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,24 @@ when not defined(nimPreviewSlimSystem):
14
14
result = " "
15
15
result .addFloat (x)
16
16
17
- proc `$` * (x: int ): string {.raises : [].} =
18
- # # Outplace version of `addInt`.
19
- result = " "
20
- result .addInt (x)
21
-
22
- proc `$` * (x: int64 ): string {.raises : [].} =
23
- # # Outplace version of `addInt`.
24
- result = " "
25
- result .addInt (x)
26
-
27
- proc `$` * (x: uint64 ): string {.raises : [].} =
28
- # # Outplace version of `addInt`.
29
- result = " "
30
- addInt (result , x)
17
+ template addIntAlias (T: typedesc ) =
18
+ proc `$` * (x: T): string {.raises : [].} =
19
+ # # Outplace version of `addInt`.
20
+ result = " "
21
+ result .addInt (x)
22
+
23
+ # need to declare for bit types as well to not clash with converters:
24
+ addIntAlias int
25
+ addIntAlias int8
26
+ addIntAlias int16
27
+ addIntAlias int32
28
+ addIntAlias int64
29
+
30
+ addIntAlias uint
31
+ addIntAlias uint8
32
+ addIntAlias uint16
33
+ addIntAlias uint32
34
+ addIntAlias uint64
31
35
32
36
# same as old `ctfeWhitelist` behavior, whether or not this is a good idea.
33
37
template gen (T) =
Original file line number Diff line number Diff line change @@ -14,21 +14,26 @@ proc rangeBase(T: typedesc): typedesc {.magic: "TypeTrait".}
14
14
15
15
proc repr * (x: NimNode ): string {.magic : " Repr" , noSideEffect .}
16
16
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
32
37
33
38
proc repr * (x: bool ): string {.magic : " BoolToStr" , noSideEffect .}
34
39
# # 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