norandomtechie / ece270-simulator

Source code for Web-Based Verilog Simulation Platform in ECE 27000 at Purdue University
25 stars 5 forks source link

SyntaxError: Unexpected token . #8

Closed eduxstad closed 3 years ago

eduxstad commented 3 years ago

You may have fixed this already but just a heads up. https://github.com/norandomtechie/ece270-simulator/blob/24d523f82b98f2cc56609bd6b60f04b654cc0831/simulate.js#L469

This question mark in settings?. causes a runtime error for me. I'm not sure whether this was intentional or not. It happens again on line 470:

https://github.com/norandomtechie/ece270-simulator/blob/24d523f82b98f2cc56609bd6b60f04b654cc0831/simulate.js#L470

Removing both questions marks fixes the error and it seemed to run fine after. My node version is v10.16.3 and here is the output for reference:

/home/eduxstad/Git/ece270-simulator/simulate.js:469
                    debugLog("Starting " + ws.unique_client + ' on ' + (payload.settings?.simulateWith == 'icarus' ? 'IcarusVerilog' : 'CVC'));
                                                                                         ^

SyntaxError: Unexpected token .
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/eduxstad/Git/ece270-simulator/cluster.js:63:25)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2021-5-17 13:10:06: uncaughtException! Details:

/home/eduxstad/Git/ece270-simulator/simulate.js:469
                    debugLog("Starting " + ws.unique_client + ' on ' + (payload.settings?.simulateWith == 'icarus' ? 'IcarusVerilog' : 'CVC'));
                                                                                         ^

SyntaxError: Unexpected token .
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/eduxstad/Git/ece270-simulator/cluster.js:63:25)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
norandomtechie commented 3 years ago

It's because node v10 doesn't support the use of the optional chaining operator, introduced in v14. node.js is always being updated, and I just always upgrade to the latest LTS version. verilog.ecn also is on v14.

I'd recommend switching, but if you're not keen on that, you can always just take out the question mark - the 'simulateWith' parameter should always be sent with the user settings anyway, so I guess it's unnecessary.