mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 19:04:46 +00:00
fixes #4470
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
trailing comma. The underlying AST is ``nnkTupleConst(newLit 1)`` for this
|
||||
example. ``nnkTupleConstr`` is a new node kind your macros need to be able
|
||||
to deal with!
|
||||
- Indexing into a ``cstring`` for the JS target is now mapped
|
||||
to ``charCodeAt``.
|
||||
|
||||
#### Breaking changes in the standard library
|
||||
|
||||
@@ -68,7 +70,7 @@
|
||||
target. To use it, compile your code with `--hotReloading:on` and use a
|
||||
helper library such as LiveReload or BrowserSync.
|
||||
|
||||
- Added ``macros.getProjectPath`` and ``ospaths.putEnv`` procs to Nim's virtual
|
||||
- Added ``macros.getProjectPath`` and ``ospaths.putEnv`` procs to Nim's virtual
|
||||
machine.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
@@ -1109,6 +1109,8 @@ proc genArrayAccess(p: PProc, n: PNode, r: var TCompRes) =
|
||||
r.res = "ord(@$1[$2])" % [r.address, r.res]
|
||||
else:
|
||||
r.res = "$1[$2]" % [r.address, r.res]
|
||||
elif ty.kind == tyCString:
|
||||
r.res = "$1.charCodeAt($2)" % [r.address, r.res]
|
||||
else:
|
||||
r.res = "$1[$2]" % [r.address, r.res]
|
||||
r.address = nil
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
output: '''true
|
||||
asdfasekjkler'''
|
||||
"""
|
||||
|
||||
# bug #4471
|
||||
@@ -9,3 +10,12 @@ when true:
|
||||
s2.setLen(0)
|
||||
# fails - s1.len == 0
|
||||
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äöü")
|
||||
|
||||
Reference in New Issue
Block a user