SOMpp tries to optimise ifFalse / ifTrue but does so in an incorrect way. Consider this contrived program:
T = (
ifTrue: x = ( ^2 )
run = (
(self ifTrue: 3) println.
)
)
On yksom and Java-SOM this prints out 2, but in SOM++ it prints out 3. The offending code is here:
diff --git a/src/compiler/Parser.cpp b/src/compiler/Parser.cpp
index 300dd06..276aeff 100644
--- a/src/compiler/Parser.cpp
+++ b/src/compiler/Parser.cpp
@@ -690,13 +690,6 @@ void Parser::keywordMessage(MethodGenerationContext* mgenc, bool super) {
StdString kw = keyword();
// special compilation for ifTrue and ifFalse
- if (!super && kw == "ifTrue:") {
- ifTrueMessage(mgenc);
- return;
- } else if (!super && kw == "ifFalse:") {
- ifFalseMessage(mgenc);
- return;
- }
formula(mgenc);
while (sym == Keyword) {
kw.append(keyword());
Basically SOMpp compiles any function called ifFalse / ifTrue into optimised versions that are only correct if the self object is a boolean. While I appreciate this is a useful optimisation for SOMpp, it seems a fairly clear violation of the intended language semantics?
SOMpp tries to optimise
ifFalse/ifTruebut does so in an incorrect way. Consider this contrived program:On yksom and Java-SOM this prints out 2, but in SOM++ it prints out 3. The offending code is here:
Basically SOMpp compiles any function called
ifFalse/ifTrueinto optimised versions that are only correct if theselfobject is a boolean. While I appreciate this is a useful optimisation for SOMpp, it seems a fairly clear violation of the intended language semantics?