uiua-lang / uiua

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

Interpreter crash: incorrect signature of recursive function #436

Closed bkDJ closed 9 months ago

bkDJ commented 9 months ago

Minimum repro:

Foo ← |3 ⟨◌|Foo -1⟩±.⊙⊙∘
Foo 2 0 0

Changing the signature to |3.2 solved it, but the above code on branch main commit e3ccd04b yields:

The application panicked (crashed).
Message:  slice index starts at 2 but ends at 1
Location: /private/tmp/rust-20240215-5649-scngkd/rustc-1.76.0-src/library/alloc/src/vec/mod.rs:2084

Backtrace omitted.

Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Error: Switch branch's signature |3 is incompatible with previous branches |1.0
  at file.ua:1:12
1 | Foo ← |3 ⟨◌|Foo -1⟩±.⊙⊙∘
               ────────
Error: Function signature mismatch: declared |3 but inferred |3.2
  at file.ua:1:7
1 | Foo ← |3 ⟨◌|Foo -1⟩±.⊙⊙∘
          ───
Error: 
  The interpreter has crashed!
  Hooray! You found a bug!
  Please report this at http://github.com/uiua-lang/uiua/issues/new or on Discord at https://discord.gg/9CU2ME4kmn.

  code:
  file.ua:1:10
  at file.ua:1:10
1 | Foo ← |3 ⟨◌|Foo -1⟩±.⊙⊙∘
             ──────────
kaikalii commented 9 months ago

Fixed in 6fb5edb76072cb8a74eb7269c1