You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically, I'm getting some kind of underflow on reference count when matching in a recursive situation. My original code had a lot of references within the matched state, but I actually managed to create a repro that doesn't keep any references in the data structure.
❯ inko run
Stack trace (the most recent call comes last):
/Users/dustyphillips/Desktop/Code/inko/repro/src/main.inko:39 in main::Main.main
/Users/dustyphillips/Desktop/Code/inko/repro/src/main.inko:1 in main::State.$dropper
/Users/dustyphillips/Desktop/Code/inko/repro/src/main.inko:24 in main::Transition.$dropper
/Users/dustyphillips/Desktop/Code/inko/repro/src/main.inko:24 in main::Transition.$dropper
/Users/dustyphillips/Desktop/Code/inko/repro/src/main.inko:1 in main::State.$dropper
Process 'Main' (0x600002d40100) panicked: can't drop a value of type 'State' as it still has 4294967295 reference(s)
Please list the exact steps necessary to reproduce the bug
class pub State {
let @transition: Transition
fn static new(transition: Transition) -> State {
State { @transition = transition }
}
fn foo {
match @transition {
case Split(Empty(state1)) -> {}
case _ -> {}
}
}
}
class pub enum Transition {
case End
case Empty(State)
case Split(Transition)
}
class async Main {
fn async main() {
State
.new(Transition.Split(Transition.Empty(State.new(Transition.End))))
.foo
}
}
The MIR for this is:
The problem here is that we forget to increment state1. This happens because the type of the register we're checking to determine if a move or increment is needed, is owned and not a reference.
The problem seems to be that as part of generating the pattern matching decision tree and variables, we don't take into account that if the root type is a ref T/mut T, any sub values matched against must also be a ref T/mut T (as we don't allow moving values out of references). The following code is probably not working correctly:
Please describe the bug
Thread here: https://discord.com/channels/1044083486509781122/1044083486509781125/1119329987489714346
Basically, I'm getting some kind of underflow on reference count when matching in a recursive situation. My original code had a lot of references within the matched state, but I actually managed to create a repro that doesn't keep any references in the data structure.
Please list the exact steps necessary to reproduce the bug
This gist is the smallest repro I was able to come up with: https://gist.github.com/dusty-phillips/a8608bcfc8fb2250134d6c776cc82300
Operating system
macos Ventura 13.4
Inko version
main
Rust version
1.69.0
The text was updated successfully, but these errors were encountered: