STR-85: Sloppy variable-scope in let-strategies
A strategydef in a let does not have global scope for its variable bindings, but there’s a leak in there.
Example:
————————–
module let-varscope
imports lib
strategies
main =
let s = ?n; debug(!"n: ")
; inc => n’; debug(!"n’: ")
; !(, n’)
in <map(s)> [1, 2, 3, 4, 5, 6]
end
—————————Compiling and running gives:
[adam@madras:misc]$ ./let-varscope
n: 1
n’: 2
n: 2
./let-varscope: rewriting failedNot that the program correctly fails on the second rebinding of n’, but it should have failed one step earlier upon rebinding n. Seemingly n has gotten local scope automagically.
If I change the !(, n’) to !(n, n’), running the program fails as expected:
[adam@madras:misc]$ ./let-varscope
n: 1
n’: 2
./let-varscope: rewriting failedI presume in the original example, the ?n is removed during compiler-optimization, since it’s not used anywhere, and thus does not cause rebinding failures.
Submitted on 11 May 2004 at 09:14
So maybe not a real bug, but it’s a bit strange.
Issue Log
STR-85, visser:
Added test; this has been fixed in the Stratego-Core refactoring.
Log in to post comments