STR-706: Possible to create annotations that cannot be matched against
It is possible to make annotations that visually look identical but still do not match:
stratego> !(1 {2}, 1 {2}); debug; equal // (basic case; works fine)
(1{2},1{2})
(1{2},1{2})
stratego> !(1 {2}, 1 {^2}); debug; equal
(1{2},1{2})
command failed
stratego> a* := 2; !(1 {2}, 1 {^[a*]}); debug; equal
(1{2},1{2})
command failed
stratego> { !1 {^2}; ?1 {a*} }
command failedAlthough it seems intuitively wrong to use this kind of annotation construction for non-list annotations, Dryad did this, and STRC accepts it without complaints. Visual inspection even seems to acknowledge that it works. Perhaps some sort of runtime “is-list” check should be introduced?
Submitted on 12 March 2007 at 10:16
Issue Log
STR-706, martin:
Or as a Stratego module (not suitable as a testsuite yet)
module foo
imports libstratego-lib
strategiesmain =
basic
; test1
; test2
; test3basic =
!(1 {2}, 1 {2})
; maybe-equaltest1 =
!(1 {2}, 1 {^2})
; maybe-equaltest2 =
a* := 2
; !(1{2}, 1 {^[a*]})
; maybe-equaltest3 =
!1 {^2}
; ?1 {a*}
; !a*
; debug(!"a* is bound to ")strategies
maybe-equal =
where( (stderr(), ["equal? ", , " "]))
; if equal then say(!“yes”) else say(!“no”) end
——————————————–Current behaviour:
——————————————–
martin@linux:~> ./foo
equal? (1{2},1{2}) yes
equal? (1{2},1{2}) no
equal? (1{2},1{2}) no
a* is bound to 2
2
——————————————–Indeed, non-lists should not be allowed after the ^ . For static terms the compiler itself can give an error, for terms including variables, there should be a runtime check.
Log in to post comments