fixes #6422
This commit is contained in:
parent
c4dcbb45f4
commit
129a599cd6
2 changed files with 49 additions and 5 deletions
|
|
@ -2,7 +2,8 @@ discard """
|
|||
output: '''1
|
||||
0
|
||||
0
|
||||
0'''
|
||||
0
|
||||
x = [a, b, c, 0, 1, 2, 3, 4, 5, 6] and y = [a, b, c, 0, 1, 2, 3, 4, 5, 6]'''
|
||||
"""
|
||||
|
||||
proc `1/1`() = echo(1 div 1)
|
||||
|
|
@ -15,3 +16,19 @@ let `1/4` = 1 div 4
|
|||
`1/2`()
|
||||
echo `1/3`
|
||||
echo `1/4`
|
||||
|
||||
# bug #6422
|
||||
|
||||
proc toCharArray1(N : static[int], s: string): array[N, char] =
|
||||
doAssert s.len <= N
|
||||
let x = cast[ptr array[N, char]](s.cstring)
|
||||
x[]
|
||||
|
||||
proc toCharArray2(N : static[int], s: string): array[N, char] =
|
||||
doAssert s.len <= N
|
||||
let x = cast[ptr array[N, char]](s.cstring)
|
||||
result = x[]
|
||||
|
||||
let x = toCharArray1(10, "abc0123456")
|
||||
let y = toCharArray2(10, "abc0123456")
|
||||
echo "x = ", $x, " and y = ", $y
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue