juancarlospaco / nodejs

Alternative StdLib for Nim for NodeJS/JavaScript targets, hijacks NodeJS StdLib for Nim
https://juancarlospaco.github.io/nodejs
MIT License
205 stars 52 forks source link

Compiling Nim with the Pretty-Printed JavaScript backend fails with a type mismatch error #13

Closed halloleo closed 1 year ago

halloleo commented 1 year ago

I am trying to build the Nim compiler with the Pretty-Printed JavaScript backend from https://github.com/juancarlospaco/nodejs/tree/main/tools.

On the .build_all.sh command I get the following error:

/Users/alba/Nim/compiler/jsgen.nim(111, 15) Error: type mismatch: got <typeof(nil)> but expected 'Rope = string'
FAILURE

(Full command output in this gist.)

Any idea what's going wrong?


BTW, the commands in your README I had to modify slightly: All backslashes (like in rm compiler\jsgen.nim) I changed to forward slashes (e.g. rm compiler/jsgen.nim).

juancarlospaco commented 1 year ago

Ropes had been changed to be actually string in devel of Nim in https://github.com/nim-lang/Nim/pull/20433, use the Nim commit before that change and it works.

halloleo commented 1 year ago

Hey @juancarlospaco, thanks for chiming in so promptly!

I now tried it with the commit you mentioend in the README (ff25103c9ab9d51821e9e8641955c8d24f7db6b8), but with that I get:

/Users/alba/devel/nim/pretty-printed-javascript/Nim/compiler/jsgen.nim(185, 29) Error: undeclared identifier: 'doAssert'
FAILURE

(To be precise what I did was:

$ git clone https://github.com/nim-lang/Nim.git
$ cd Nim
$ git checkout ff25103c9ab9d51821e9e8641955c8d24f7db6b8
$ rm compiler/jsgen.nim
$ rm lib/system/jssys.nim
$ curl -Lo compiler/jsgen.nim https://raw.githubusercontent.com/juancarlospaco/nodejs/main/tools/jsgen.nim
$ curl -Lo lib/system/jssys.nim https://raw.githubusercontent.com/juancarlospaco/nodejs/main/tools/jssys.nim
$ ./build_all.sh

)

juancarlospaco commented 1 year ago

Try 3fef2fd52c86ba922187ca03026b09ceb70b5d3d.

Assertions had been removed in devel of Nim, they are a separate module now https://nim-lang.github.io/Nim/assertions.html

juancarlospaco commented 1 year ago

Ideally those changes should be in mainstream to avoid these kind of out of sync problems... :shrug:

halloleo commented 1 year ago

Thanks. Got Nim compiled with the commit 3fef2fd52c86ba922187ca03026b09ceb70b5d3d.

Will try your JS backend out! 😄

Should I check out the nodeJS repo and create a little PR adding the commit info your README?

juancarlospaco commented 1 year ago

It was like that https://github.com/juancarlospaco/nodejs/commit/a578730d77949ab0d30fdf53cb3f8fa98e04a44f It was just too much big changes in Nim devel, but it is maintained. Any improvements are welcome.

halloleo commented 1 year ago

I see!

But I don't understand, why did you change in the README the commit your stuff is suppose to work with from 3fef2fd52c86ba922187ca03026b09ceb70b5d3d to ff25103c9ab9d51821e9e8641955c8d24f7db6b8, if the latter doesn't work?

Sorry, this might be a total newbie question...

juancarlospaco commented 1 year ago

Bug, mistake.

halloleo commented 1 year ago

I see. Should it be changes back?

juancarlospaco commented 1 year ago

Yes can be, until the patch is fixed.

juancarlospaco commented 1 year ago

So basically it works, it may not be always in sync with devel but I see no better way if it is not accepted upstream, and then nothing really critical going on here, I will close for now...

halloleo commented 1 year ago

Fair enough. I don't understand the intricacies why it changes over time which commit works, but that's what it seems to be.

I might add a note about it on the forum or wiki?

juancarlospaco commented 1 year ago

why it changes over time which commit works

Because Nim mainstream changes, ideally this would be somehow integrated into Nim, at least with some changes, at least for Nim 3.0, but is hard to convince core devs, but I think that would bring more donations and contributions to Nim in the long run.