summaryrefslogtreecommitdiff
path: root/Source/Dafny
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2010-06-08 20:09:12 +0000
committerGravatar rustanleino <unknown>2010-06-08 20:09:12 +0000
commit1e156f9e83cb5ace0f74330f2aa49f8ce09d0afe (patch)
tree17ec0bd23994faa50bd8a60c16defc6dc092eef8 /Source/Dafny
parent5696ff18488fac981db0310fc92f7d8fd1a8dfae (diff)
Dafny: Fix type bug in SplitExpr translation.
Diffstat (limited to 'Source/Dafny')
-rw-r--r--Source/Dafny/DafnyAst.ssc13
-rw-r--r--Source/Dafny/Translator.ssc10
2 files changed, 22 insertions, 1 deletions
diff --git a/Source/Dafny/DafnyAst.ssc b/Source/Dafny/DafnyAst.ssc
index ef047c4d..1ea2e150 100644
--- a/Source/Dafny/DafnyAst.ssc
+++ b/Source/Dafny/DafnyAst.ssc
@@ -1333,6 +1333,19 @@ namespace Microsoft.Dafny
}
}
+ public class BoxingCastExpr : Expression { // a BoxingCastExpr is used only as a temporary placeholding during translation
+ public readonly Expression! E;
+ public readonly Type! FromType;
+ public readonly Type! ToType;
+
+ public BoxingCastExpr(Expression! e, Type! fromType, Type! toType) {
+ base(e.tok);
+ E = e;
+ FromType = fromType;
+ ToType = toType;
+ }
+ }
+
public class MaybeFreeExpression {
public readonly Expression! E;
public readonly bool IsFree;
diff --git a/Source/Dafny/Translator.ssc b/Source/Dafny/Translator.ssc
index 35e8cdc1..caa8fb2b 100644
--- a/Source/Dafny/Translator.ssc
+++ b/Source/Dafny/Translator.ssc
@@ -3071,6 +3071,10 @@ namespace Microsoft.Dafny {
Bpl.Expr els = TrExpr(e.Els);
return translator.FunctionCall(expr.tok, BuiltinFunction.IfThenElse, translator.TrType((!)expr.Type), g, thn, els);
+ } else if (expr is BoxingCastExpr) {
+ BoxingCastExpr e = (BoxingCastExpr)expr;
+ return CondApplyBox(e.tok, TrExpr(e.E), e.FromType, e.ToType);
+
} else {
assert false; // unexpected expression
}
@@ -3607,7 +3611,11 @@ namespace Microsoft.Dafny {
Dictionary<IVariable,Expression!> substMap = new Dictionary<IVariable,Expression!>();
assert fexp.Args.Count == fexp.Function.Formals.Count;
for (int i = 0; i < fexp.Function.Formals.Count; i++) {
- substMap.Add(fexp.Function.Formals[i], fexp.Args[i]);
+ Formal p = fexp.Function.Formals[i];
+ Expression arg = fexp.Args[i];
+ arg = new BoxingCastExpr(arg, (!)arg.Type, p.Type);
+ arg.Type = p.Type; // resolve here
+ substMap.Add(p, arg);
}
Expression body = Substitute(fexp.Function.Body, fexp.Receiver, substMap);
foreach (Expression se in SplitExpr(body, false)) {