uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.63k stars 116 forks source link

The interpreter crashed: range start index 1 out of range for slice of length 0 #302

Closed Rembane closed 11 months ago

Rembane commented 11 months ago

I'm creating an issue to track this issue. Please let me know if you need anything more from me.

RUST_BACKTRACE=full uiua watch --no-format
Watching for changes... (end with ctrl+C, use `uiua help` to see options)
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Advice: Split this line into multiple lines (heuristic: 65/53)
  at main.ua:12:1
12 | ⍉≡(∘▽+1)¤⊙(⍉≡(∘▽+1)¤)⬚0+⊙(:⬚0+:)⊙⊙∩(⍥(⊂0):[])∩(°⊚⊚=0/+)⊃⍉(⊙°⊟:△.).=@#⊜∘≠@\n. Input
     ──────────────────────────────────────────────────────────────────────────────────
The application panicked (crashed).
Message:  range start index 1 out of range for slice of length 0
Location: /home/hace/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uiua-0.6.1/src/value.rs:217

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                              ⋮ 7 frames hidden ⋮
 8: core::slice::index::slice_start_index_len_fail_rt::ha112e85e859dc7f7
    at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/slice/index.rs:52
 9: core::slice::index::slice_start_index_len_fail::h5dd4fb20f57b6c6a
    at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/slice/index.rs:40
10: uiua::value::Value::prototype_row::ha09277a649c43429
    at <unknown source file>
11: uiua::algorithm::zip::rows2::h19398557849636a6
    at <unknown source file>
12: uiua::primitive::<impl uiua::primitive::defs::Primitive>::run::h19c5d3772a4bcd9d
    at <unknown source file>
13: uiua::run::Uiua::exec::h2a38ba065c7a2eec
    at <unknown source file>
14: uiua::run::Uiua::call_with_span::hcdc2715d3f293105
    at <unknown source file>
15: uiua::algorithm::zip::rows2::h19398557849636a6
    at <unknown source file>
16: uiua::primitive::<impl uiua::primitive::defs::Primitive>::run::h19c5d3772a4bcd9d
    at <unknown source file>
17: uiua::run::Uiua::exec::h2a38ba065c7a2eec
    at <unknown source file>
18: uiua::compile::<impl uiua::run::Uiua>::items::h85e3ba74bd1b7fe4
    at <unknown source file>
19: uiua::run::Uiua::load_impl::hf44775d9b94de7d1
    at <unknown source file>
20: uiua::run::Uiua::load_file::h8d2e38571da37be5
    at <unknown source file>
21: uiua::main::h7d0bab28d08621dc
    at <unknown source file>
22: std::sys_common::backtrace::__rust_begin_short_backtrace::h648c364573c71dd8
    at <unknown source file>
23: main
    at <unknown source file>
24: __libc_start_main
    at <unknown source file>
25: _start
    at <unknown source file>
Error: The interpreter has crashed!
  Hooray! You found a bug!
  Please report this at http://github.com/uiua-lang/uiua/issues/new

  code:
  main.ua:15:4
  Input ← $ ...#......
          $ .......#..
          $ #.........
          $ ..........
          $ ......#...
          $ .#........
          $ .........#
          $ ..........
          $ .......#..
          $ #...#.....

  ⍉≡(∘▽+1)¤⊙(⍉≡(∘▽+1)¤)⬚0+⊙(:⬚0+:)⊙⊙∩(⍥(⊂0):[])∩(°⊚⊚=0/+)⊃⍉(⊙°⊟:△.).=@#⊜∘≠@\n. Input
  ⇡⧻.
  # ≡(□≡(⊂?)⊙(¤⊚))
  ≡(□≡(⊂)⊚:)
  at main.ua:15:4
15 | ≡(□≡(⊂)⊚:)
        ─
ikepaul commented 11 months ago

I got the same bug when doing rows(join). Edit: Did some testing: ≡(+) [1 2 3] ¤ 1 # Works ≡(+) ¤ 1 [1 2 3] # Works ≡(+) [] [] # Works ≡(+) [] [] # Works ≡(+) [1 2 3] [] # Error, as it should ≡(+) [] [1 2 3] # Error, as it should ≡(+) [] ¤ 1 # Crashes ≡(+) ¤ 1 [] # Crashes ≡(+) [] [1] # Crashes ≡(+) [1] [] # Crashes

So theres an error when fixing a value and trying to iterate over another array, if that other array is empty.

kaikalii commented 11 months ago

This was fixed recently. You can get the version with the fix with

uiua update --main
Rembane commented 11 months ago

Awesome! Thank you!