From 03770daba44fb9ac5c21729d0b32cda10f8767bd Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 11 Apr 2017 02:22:13 +0300 Subject: [PATCH] allow StmtLists to pass through semExprWithType This fix was necessary in order to fix the lambda lifting used in the "jsffi" module, which relies on turning nkStmtList into nkLambda in a catch-all dot operator. --- lib/js/jsffi.nim | 5 +---- tests/js/tjsffi.nim | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/js/jsffi.nim b/lib/js/jsffi.nim index e0310e33a4..3b3f38e415 100644 --- a/lib/js/jsffi.nim +++ b/lib/js/jsffi.nim @@ -78,6 +78,7 @@ type ## Statically typed wrapper around a JavaScript object. NotString = concept c c isnot string + js* = JsObject var jsarguments* {.importc: "arguments", nodecl}: JsObject ## JavaScript's arguments pseudo-variable @@ -133,10 +134,6 @@ proc `/=` *(x, y: JsObject): JsObject {. importcpp: "(# /= #)", discardable .} proc `%=` *(x, y: JsObject): JsObject {. importcpp: "(# %= #)", discardable .} proc `++` *(x: JsObject): JsObject {. importcpp: "(++#)" .} proc `--` *(x: JsObject): JsObject {. importcpp: "(--#)" .} -# proc `==` *(x, y: JsObject): JsObject {. importcpp: "(# == #)" .} -# proc `===`*(x, y: JsObject): JsObject {. importcpp: "(# === #)" .} -# proc `!=` *(x, y: JsObject): JsObject {. importcpp: "(# != #)" .} -# proc `!==`*(x, y: JsObject): JsObject {. importcpp: "(# !== #)" .} proc `>` *(x, y: JsObject): JsObject {. importcpp: "(# > #)" .} proc `<` *(x, y: JsObject): JsObject {. importcpp: "(# < #)" .} proc `>=` *(x, y: JsObject): JsObject {. importcpp: "(# >= #)" .} diff --git a/tests/js/tjsffi.nim b/tests/js/tjsffi.nim index 99a475a8eb..e4aad4b997 100644 --- a/tests/js/tjsffi.nim +++ b/tests/js/tjsffi.nim @@ -21,6 +21,7 @@ true 12 Event { name: 'click: test' } Event { name: 'reloaded: test' } +Event { name: 'updates: test' } ''' """ @@ -295,7 +296,7 @@ block: """ function Event(name) { this.name = name; } function on(eventName, eventHandler) { eventHandler(new Event(eventName + ": test")); } - var jslib = { "on": on }; + var jslib = { "on": on, "subscribe": on }; """ .} @@ -311,3 +312,8 @@ block: jslib.on "reloaded" do: console.log jsarguments[0] + # this test case is different from the above, because + # `subscribe` is not overloaded in the current scope + jslib.subscribe "updates": + console.log jsarguments[0] +