Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on unit definition using square roots #561

Closed
ngollon opened this issue Sep 11, 2024 · 3 comments · Fixed by #614
Closed

Error on unit definition using square roots #561

ngollon opened this issue Sep 11, 2024 · 3 comments · Fixed by #614
Labels
bug Something isn't working
Milestone

Comments

@ngollon
Copy link

ngollon commented Sep 11, 2024

Using the unit definition
unit test = sqrt(kg)

the web interface breaks and always shows the error

[USER]: unreachable
RuntimeError: unreachable
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[655]:0xccfad
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[1471]:0x10f350
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[191]:0x84d30
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[108]:0x654cd
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[66]:0x4bc26
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[54]:0x3f8fc
    at https://numbat.dev/pkg/numbat_wasm_bg.wasm:wasm-function[843]:0xdd040
    at Numbat.interpret (https://numbat.dev/pkg/numbat_wasm.js:257:26)
    at ce.fn.init.interpret (https://numbat.dev/index.js:68:29)
    at s (https://numbat.dev/jquery.terminal.min.js:46:123939)

Link: https://numbat.dev/?q=unit+test+%3D+sqrt%28kg%29⏎test

@Goju-Ryu
Copy link
Contributor

Goju-Ryu commented Sep 11, 2024

I just tried the same thing with unit example = sqrt(m) and got an error about recursion in rust.
See example here

To make it happen you have to write to lines yourself, the first just being one of the units and the other on the next. The first line gives the reported error and the second gives the recursion error.

[USER]: recursive use of an object detected which would
lead to unsafe aliasing in rust

@https://numbat.dev/pkg/numbat_wasm.js:535:24
<?>.wasm-function[1715]@[wasm code]
<?>.wasm-function[1714]@[wasm code]
<?>.wasm-function[843]@[wasm code]
interpret@https://numbat.dev/pkg/numbat_wasm.js:257:42
interpret@https://numbat.dev/index.js:68:38
s@https://numbat.dev/jquery.terminal.min.js:46:123943
me@https://numbat.dev/jquery.terminal.min.js:46:124921
ENTER@https://numbat.dev/jquery.terminal.min.js:46:45312
it@https://numbat.dev/jquery.terminal.min.js:46:64967
dispatch@https://numbat.dev/jquery.min.js:2:40002

Update: same error happens if you use just the example definition and try to print it twice the same way as in the original example.

@sharkdp
Copy link
Owner

sharkdp commented Sep 11, 2024

Thank you very much for reporting this. Running this in debug mode on the command line shows a failing debug-assertion:

>>> unit test = sqrt(kg)

  unit test: Mass^(1/2) = sqrt(kilogram)

>>> test
thread 'main' panicked at numbat/src/unit.rs:140:21:
assertion failed: key[0].1.is_integer()

@sharkdp sharkdp added the bug Something isn't working label Sep 11, 2024
@sharkdp sharkdp added this to the 1.14 milestone Oct 9, 2024
@sharkdp
Copy link
Owner

sharkdp commented Oct 11, 2024

This is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants