This commit is contained in:
Andreas Rumpf
2018-04-13 23:41:31 +02:00
parent a3cf1cff5b
commit d7cc9016f3
3 changed files with 16 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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äöü")