pico-engine icon indicating copy to clipboard operation
pico-engine copied to clipboard

Issue with optional chaining in krl-compiler

Open kylona opened this issue 2 years ago • 1 comments

I ran into an issue trying to install the krl-compiler.

I was following the instructions here: https://picolabs.atlassian.net/wiki/spaces/docs/pages/31544297/Developer+Tips+for+Pico+Engine#DeveloperTipsforPicoEngine-ParsingKRL

npm install -g krl-compiler
krl-compiler -v

The npm command finished successfully. And I think I got the code installed correctly. However, when running the command to check the version I ran into this error:

caffeine:distributedSystems kylestorey$ krl-compiler -v
/Users/kylestorey/n/lib/node_modules/krl-compiler/bin/krl-compiler:66
        if (err?.where?.line && err?.where?.col) {
                ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1072:16)
    at Module._compile (internal/modules/cjs/loader.js:1122:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

It looks like optional chaining is not being parsed correctly. This likely is an issue with my node setup. This is the node version I'm running.

caffeine:distributedSystems kylestorey$ node -v
v12.16.1

I am running on an old Mac that runs high sierra.

I was able to work around it by changing line 66 of krl-compiler/bin/krl-compiler:66 from:

if (err?.where?.line && err?.where?.col) { to if (err && err.where && err.where.line && err.where.col) { which I believe is semanticly equivalent.

Similarly I changed line 73 to:

if (err && err.where && err.where.excerpt) { Any ideas about what might be causing this?

kylona avatar Jan 09 '22 00:01 kylona