From d20e4e0df4a384c4b3249eda8a487d998e9eee47 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 7 Apr 2014 01:59:17 +0200 Subject: [PATCH 1/3] updated news.txt --- web/news.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/news.txt b/web/news.txt index 536cce534..4aaf10992 100644 --- a/web/news.txt +++ b/web/news.txt @@ -30,7 +30,7 @@ kqueue has not been implemented yet but will be in the future. The Asynchronous IO API provides both a callback interface and an interface which allows you to write code as you would if you were writing synchronous code. The latter is done through -the use of an ``await`` keyword which behaves similar to C#'s await. The +the use of an ``await`` macro which behaves similar to C#'s await. The following is a very simple chat server demonstrating Nimrod's new async capabilities. @@ -59,6 +59,11 @@ capabilities. serve() runForever() + +Note that this feature has been implemented with Nimrod's macro system and so +``await`` and ``async`` are no keywords. + + Library Additions ----------------- From abb701082065334fd171aaa05c530b611c5aef50 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 7 Apr 2014 14:21:33 +0200 Subject: [PATCH 2/3] fixes #1063 --- compiler/semtypes.nim | 12 +++++++++++- compiler/vmgen.nim | 2 +- tests/vm/tarrayboundeval.nim | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/vm/tarrayboundeval.nim diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index c53dc0f7d..e8dcea731 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -225,8 +225,18 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType = # properly filled-out in semtypinst (see how tyStaticExpr # is handled there). indx = makeRangeWithStaticExpr(c, e) - else: + elif e.kind == nkIdent: indx = e.typ.skipTypes({tyTypeDesc}) + else: + let x = semConstExpr(c, e) + if x.kind in {nkIntLit..nkUInt64Lit}: + indx = makeRangeType(c, 0, x.intVal-1, n.info, + x.typ.skipTypes({tyTypeDesc})) + else: + indx = x.typ.skipTypes({tyTypeDesc}) + if not isOrdinalType(indx): + localError(n[1].info, errOrdinalTypeExpected) + #localError(n[1].info, errConstExprExpected) addSonSkipIntLit(result, indx) if indx.kind == tyGenericInst: indx = lastSon(indx) if indx.kind notin {tyGenericParam, tyStatic, tyFromExpr}: diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 434cb0932..7c0c3d4f5 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1501,7 +1501,7 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) = else: localError(n.info, errGenerated, "VM is not allowed to 'cast'") else: - internalError n.info, "too implement " & $n.kind + internalError n.info, "cannot generate VM code for " & n.renderTree proc removeLastEof(c: PCtx) = let last = c.code.len-1 diff --git a/tests/vm/tarrayboundeval.nim b/tests/vm/tarrayboundeval.nim new file mode 100644 index 000000000..9b33a2415 --- /dev/null +++ b/tests/vm/tarrayboundeval.nim @@ -0,0 +1,23 @@ +discard """ + output: '''7 +8 8''' +""" + +#bug 1063 + +const + KeyMax = 227 + myconst = int((KeyMax + 31) / 32) + +type + FU = array[int((KeyMax + 31) / 32), cuint] + +echo FU.high + +type + PKeyboard* = ptr object + TKeyboardState* = object + display*: pointer + internal: array[int((KeyMax + 31)/32), cuint] + +echo myconst, " ", int((KeyMax + 31) / 32) From 3197ec8e7289fc0861af05f8ecc357b54099f702 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 7 Apr 2014 15:46:02 +0200 Subject: [PATCH 3/3] make tests green again --- compiler/semtypes.nim | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index e8dcea731..a563cf06c 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -234,8 +234,6 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType = x.typ.skipTypes({tyTypeDesc})) else: indx = x.typ.skipTypes({tyTypeDesc}) - if not isOrdinalType(indx): - localError(n[1].info, errOrdinalTypeExpected) #localError(n[1].info, errConstExprExpected) addSonSkipIntLit(result, indx) if indx.kind == tyGenericInst: indx = lastSon(indx)