There are many reasonable cases where we might want to allow a dynamic format string. Support that situation by adding the new invariants that are needed for those cases.
20 lines
626 B
Plaintext
20 lines
626 B
Plaintext
-- main.mcl --
|
|
import "fmt"
|
|
|
|
$str1 = "big"
|
|
$str2 = "world"
|
|
|
|
# FIXME: We'd like to pre-compute the interpolation if we can, so that we can
|
|
# check this code statically... For now, we can't, so it's only possible with
|
|
# the PrintfAllowNonStaticFormat option enabled. This isn't bad per se, however
|
|
# any static compilation/optimization we can by "running early" would be great.
|
|
test fmt.printf("hello ${str1} %s", $str2) {}
|
|
test "hello " + "small" + " " + $str2 {}
|
|
print "print1" {
|
|
msg => fmt.printf("hello ${str1} %s", $str2),
|
|
}
|
|
-- OUTPUT --
|
|
Vertex: test[hello big world]
|
|
Vertex: test[hello small world]
|
|
Vertex: print[print1]
|