risor-io/risor

f-strings in closures don't have access to outer scope

Closed this issue · 2 comments

For example:

func foo(a, b, c) {
	return func(d) {
		return '{a} {b}'
	}
}
foo("hello")("go")

Results in a panic: runtime error: invalid memory address or nil pointer dereference

However, when I bring the closure's variables into scope, I get the correct string:

func foo(a) {
	return func(b) {
		a := a
		return '{a} {b}'
	}
}
foo("hello")("go")

💯 Good find.

I'll work on this.

This is fixed in the new v0.14.0 release.