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

Bug in buffer/push-word #23

Closed
jfcap opened this issue Jan 26, 2019 · 1 comment
Closed

Bug in buffer/push-word #23

jfcap opened this issue Jan 26, 2019 · 1 comment

Comments

@jfcap
Copy link

jfcap commented Jan 26, 2019

I've found a little bug in buffer.c

janet:353:> (buffer/push-word @"" 1)
error in repl: bad slot #0, expected number, got @""
  in cfunction buffer/push-word
  in _thunk [repl] at (354:377) (tailcall)

Here is a patch

diff --git a/src/core/buffer.c b/src/core/buffer.c
index d318a6e..7987d79 100644
--- a/src/core/buffer.c
+++ b/src/core/buffer.c
@@ -192,7 +192,7 @@ static Janet cfun_buffer_word(int32_t argc, Janet *argv) {
     janet_arity(argc, 1, -1);
     JanetBuffer *buffer = janet_getbuffer(argv, 0);
     for (i = 1; i < argc; i++) {
-        double number = janet_getnumber(argv, 0);
+        double number = janet_getnumber(argv, i);
         uint32_t word = (uint32_t) number;
         if (word != number)
             janet_panicf("cannot convert %v to machine word", argv[0]);
bakpakin added a commit that referenced this issue Jan 26, 2019
@bakpakin
Copy link
Member

Thanks, fixed in e755f98

kspalaiologos pushed a commit to kspalaiologos/janet that referenced this issue Jan 17, 2021
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