grol-io / grol

Go REPL Open Language
https://grol.io
Apache License 2.0
13 stars 1 forks source link

max recursion limit overflow not being detected #193

Closed MikalaiLappo closed 2 weeks ago

MikalaiLappo commented 2 weeks ago

Sample code:

func toLinkedList(arr) {
  if len(arr) == 0 {
    nil
  } else {
    { "value": first(arr), "next": toLinkedList(rest(arr)) }
  }
} 

func reverseLinkedList(list, acc) {
  if list == nil {
    acc // <- missing return statement
  }
  // the call overlooked by max recursion check
  // (hangs forever without a symptom)
  reverseLinkedList(list.next, { "value": list.value, "next": acc }) 
} 

ll = toLinkedList(1 : 5)
println(reverseLinkedList(ll, nil))
ldemailly commented 2 weeks ago

fixed (more generally) in #198