Need help with EmberJson package

I got some errors when using EmberJson. Can anyone help?

$ mojo life.mojo
/mnt/Archive/Documents/Programming/Mojo/life/life.mojo:3:17: error: cannot call function that may raise in a context that cannot raise
var json = parse('{"key": 123}')
           ~~~~~^~~~~~~~~~~~~~~~
/mnt/Archive/Documents/Programming/Mojo/life/life.mojo:3:17: note: try surrounding the call in a 'try' block
var json = parse('{"key": 123}')
                ^
mojo: error: failed to parse the provided Mojo source module

@bgreni is the package creator :slight_smile:

The parse function can raise exceptions, so you much either mark the function containing it as raises as well, or wrap it in a try/except block to handle any possible errors.

I got another error:

from emberjson import *

fn main() raises:
    var json = parse('{"key": 123}')
    print(to_string(json)) # prints {"key":123}
    print(to_string[pretty=True](json))
$ mojo life.mojo
Please submit a bug report to https://github.com/modular/modular/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0.	Program arguments: mojo life.mojo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  mojo                      0x000055e2e9bf402b
1  mojo                      0x000055e2e9bf1dc9
2  mojo                      0x000055e2e9bf46da
3  libc.so.6                 0x00007fcf2ba67070
4  libc.so.6                 0x00007fcf2bac0334
5  libc.so.6                 0x00007fcf2ba66fbe gsignal + 30
6  libAsyncRTMojoBindings.so 0x00007fcf2dbb1542
7  libc.so.6                 0x00007fcf2ba67070
8  mojo                      0x000055e2e9b68507
9  mojo                      0x000055e2e6db7300
10 mojo                      0x000055e2e6da7632
11 mojo                      0x000055e2e6fe0d29
12 mojo                      0x000055e2e6fe155b
13 mojo                      0x000055e2e6fe54e7
14 mojo                      0x000055e2e6fe7da7
15 mojo                      0x000055e2e6fea7e1
16 mojo                      0x000055e2e66bd3f3
17 mojo                      0x000055e2e66bca07
18 mojo                      0x000055e2e66d438b
19 mojo                      0x000055e2e66e9193
20 mojo                      0x000055e2e66d1f60
21 mojo                      0x000055e2e66d1b4e
22 mojo                      0x000055e2e66d172a
23 mojo                      0x000055e2e6c2077d
24 mojo                      0x000055e2e6c1f3ad
25 mojo                      0x000055e2e66c1a69
26 mojo                      0x000055e2e65463ee
27 mojo                      0x000055e2e65509e3
28 libc.so.6                 0x00007fcf2ba50348
29 libc.so.6                 0x00007fcf2ba5040b __libc_start_main + 139
30 mojo                      0x000055e2e6522d25
mojo crashed!
Please file a bug report.
Segmentation fault (core dumped)

That would be a compiler crash, could you provide some info on your environment? Max and emberjson versions, operating system, etc

AlmaLinux 10
max-nightly
Emberjson from git clone https://github.com/bgreni/EmberJson command. I do not know its version.

Using the repo head is a bit risky from a stability standpoint. However, I can’t reproduce on my mac machine so I’ll have to try and boot up a Linux VM at some point.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.