From 6cc50ec3163c79b120bf17e32810946bad6b3893 Mon Sep 17 00:00:00 2001 From: metagn Date: Thu, 19 Sep 2024 01:35:29 +0300 Subject: fix system for nimscript config files on js backend (#24135) fixes #21441 When compiling for JS, nimscript config files have both `defined(js)` and `defined(nimscript)` be true at the same time. This is required so that the nimscript config file knows the current compilation is for the JS backend. However the system module doesn't account for this in some cases, defining JS-specific code or not defining nimscript-specific code when compiling such nimscript files. To fix this, have the `nimscript` define take priority over the `js` one. --- lib/system.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/system.nim b/lib/system.nim index 5f4847b7d..2f9cdc5f9 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2085,7 +2085,8 @@ when notJSnotNims: proc cmpMem(a, b: pointer, size: Natural): int = nimCmpMem(a, b, size).int -when not defined(js): +when not defined(js) or defined(nimscript): + # nimscript can be defined if config file for js compilation proc cmp(x, y: string): int = when nimvm: if x < y: result = -1 @@ -2365,7 +2366,8 @@ proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magi from std/private/digitsutils import addInt export addInt -when defined(js): +when defined(js) and not defined(nimscript): + # nimscript can be defined if config file for js compilation include "system/jssys" include "system/reprjs" -- cgit 1.4.1-2-gfad0