fixes #4470
This commit is contained in:
parent
a3cf1cff5b
commit
d7cc9016f3
3 changed files with 16 additions and 2 deletions
|
|
@ -9,6 +9,8 @@
|
||||||
trailing comma. The underlying AST is ``nnkTupleConst(newLit 1)`` for this
|
trailing comma. The underlying AST is ``nnkTupleConst(newLit 1)`` for this
|
||||||
example. ``nnkTupleConstr`` is a new node kind your macros need to be able
|
example. ``nnkTupleConstr`` is a new node kind your macros need to be able
|
||||||
to deal with!
|
to deal with!
|
||||||
|
- Indexing into a ``cstring`` for the JS target is now mapped
|
||||||
|
to ``charCodeAt``.
|
||||||
|
|
||||||
#### Breaking changes in the standard library
|
#### Breaking changes in the standard library
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1109,6 +1109,8 @@ proc genArrayAccess(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
r.res = "ord(@$1[$2])" % [r.address, r.res]
|
r.res = "ord(@$1[$2])" % [r.address, r.res]
|
||||||
else:
|
else:
|
||||||
r.res = "$1[$2]" % [r.address, r.res]
|
r.res = "$1[$2]" % [r.address, r.res]
|
||||||
|
elif ty.kind == tyCString:
|
||||||
|
r.res = "$1.charCodeAt($2)" % [r.address, r.res]
|
||||||
else:
|
else:
|
||||||
r.res = "$1[$2]" % [r.address, r.res]
|
r.res = "$1[$2]" % [r.address, r.res]
|
||||||
r.address = nil
|
r.address = nil
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''true'''
|
output: '''true
|
||||||
|
asdfasekjkler'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #4471
|
# bug #4471
|
||||||
|
|
@ -9,3 +10,12 @@ when true:
|
||||||
s2.setLen(0)
|
s2.setLen(0)
|
||||||
# fails - s1.len == 0
|
# fails - s1.len == 0
|
||||||
echo s1.len == 3
|
echo s1.len == 3
|
||||||
|
|
||||||
|
# bug #4470
|
||||||
|
proc main(s: cstring): string =
|
||||||
|
result = newString(0)
|
||||||
|
for i in 0..<s.len:
|
||||||
|
if s[i] >= 'a' and s[i] <= 'z':
|
||||||
|
result.add s[i]
|
||||||
|
|
||||||
|
echo main("asdfasekjkleräöü")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue