risor-io/risor

Bug: too many nested for loops start stepping on each other

Closed this issue · 1 comments

I've a hard time getting this down to as small of an example as possible. Here's what I got:

my_list := ['a', 'banana', 'c', 'd']

func get_match(c) {
	for _, s := range my_list {
		if strings.has_prefix(s, c) {
			return s
		}
	}
}

func do_thing_with_string(s) {
	for _, c := range s {
		print('char: "{c}"')

		_ = get_match(c)
	}
}

for _, s := range my_list {
	print('for my_list start: {s}')
	do_thing_with_string(s)
	print('for my_list end: {s}')
}
$ risor bug.risor
for my_list start: a
char: "a"
char: "banana"
char: "c"
char: "d"
for my_list end: a

The behavior here is just super weird. Don't know what's really going on.

Thanks @applejag I’ll debug this.