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

Invalid_argument(Array.get) from nekoc #184

Open
btiffin opened this issue Aug 15, 2018 · 1 comment
Open

Invalid_argument(Array.get) from nekoc #184

btiffin opened this issue Aug 15, 2018 · 1 comment

Comments

@btiffin
Copy link

btiffin commented Aug 15, 2018

This should be infinite loop code, I think, while experimenting with Neko programming.

prompt$ cat gotos.neko
$print("start");
$goto(next);

$print("skip");

next:
$print("continue");
$goto(end);

$print("skip");

end: 
$print("end");

$goto(next);

Instead, the VM translation fails

prompt$ nekoc gotos.neko
Called from neko/Main.nml line 153 
Called from core/Args.nml line 57
Called from neko/Main.nml line 68
Called from core/Array.nml line 120
Called from neko/Bytecode.nml line 320
Called from core/Core.nml line 179
Called from core/Core.nml line 212
Exception : Invalid_argument(Array.get)

Fedora 27, from packages nekovm, nekovm-devel 2.2.0-4 x86_64

Replace the last $goto and all goes well.

@ppenzin
Copy link
Collaborator

ppenzin commented Aug 16, 2018

I can reproduce it with ToT revision on FreeBSD. It looks like an out-of-bounds error from the code calculating the jump target.

$ cat go2.neko
$print("start");

next:
$print("continue");

$goto(next);

$ bin/nekoc go2.neko
Called from neko/Main.nml line 153
Called from core/Args.nml line 57
Called from neko/Main.nml line 68
Called from core/Array.nml line 120
Called from neko/Bytecode.nml line 320
Called from core/Core.nml line 179
Called from core/Core.nml line 212
Exception : Invalid_argument(Array.get)

What is interesting, is that removing the first $print makes the error go away as well:

$ cat go2+.neko
next:
$print("continue");

$goto(next);

$ bin/nekoc go2+.neko
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants