yglukhov / nimx

GUI library
MIT License
1.09k stars 75 forks source link

JS mode is completely broken since November #520

Closed DiThi closed 1 year ago

DiThi commented 1 year ago

JS mode is broken since commit 7cda4e15f03a379bf40f88263fbcdcf95d199c16.

Steps to reproduce:

Result with 7cda4e15f03a379bf40f88263fbcdcf95d199c16:

[...]/nimx/nimx/assets/asset_loading.nim(41, 24) Error: type mismatch: got <array[0..0, string], openArray[string], proc (url: string, path: string, cache: AssetCache, handler: proc (){.closure, gcsafe.}){.closure, locks: <unknown>.}>
but expected one of:
[long output]

Result with head:

[...]/nimx/nimx/private/windows/js_canvas_window.nim(298, 27) Error: type mismatch: got 'proc (): Window{.locks: <unknown>.}' for 'proc (): Window = result = newJSWindowByFillingBrowserWindow()' but expected 'proc (): Window{.closure, gcsafe.}'
  Pragma mismatch: got '{..}', but expected '{.gcsafe.}'.

Result with head after adding {.gcsafe.} to that proc and init in js_canvas_window.nim:

[...]/nimx/nimx/formatted_text.nim(731, 25) Error: type mismatch: got <GraphicsContext, Rect, Point, FormattedText, proc (c: GraphicsContext, t: FormattedText, p: var Point, curLine: int, curAttrIndex: int, str: string){.locks: <unknown>.}>
but expected one of:
[VERY long output, very difficult to understand as it basically outputs a full proc source code twice as "expression"]

These changes to use .gcsafe. should probably have a condition for JS, or some way to tell the compile to ignore those altogether.

There's no difference with --threads:off and barely any change by using nim devel instead of stable.

ACDouble commented 1 year ago

Can confirm. On a fresh install of Nim 1.6.12, Windows 10, installed the package via nimble install nimx

Using the code available on the main page, compiling with nim js test.nim, it fails with the above error.

yglukhov commented 1 year ago

Yes, js support is no longer a goal since wasm is superior in all ways. Sorry this was not communicated earlier.