grain-lang / grain

The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
https://grain-lang.org/
GNU Lesser General Public License v3.0
3.28k stars 115 forks source link

Garbage Collection Issue #2199

Closed spotandjake closed 2 hours ago

spotandjake commented 2 hours ago

The code below causes an unreachable error at the print statement, this seems to be a memory issue though as when making a minimal implementation to reproduce I went back and forth between unreachable errors and DecRef issues. Interesting it seems related to the Set.empty with Map.empty experiencing the same properties. It doesn't just seem to be in relation to closures though as Number.pi is a value that can be passed perfectly fine the loop also needs to run 4 times.

module Main
from "set" include Set
use Set.{ module Immutable as Set }
from "array" include Array
Array.reduce((argResult, arg) => {
  Set.empty
}, Set.empty, [> 1, 1, 1, 1])
print("me")

This also is causing the online playground to timeout (indicting the bug is occurring there too)

spotandjake commented 2 hours ago

Closing as upon furthur investigation it seems as though this is a duplicate of #2197