Skip to content

Commit c2c5c2c

Browse files
feat!: Remove /ironFlag flag (#1083)
* feat!: Remove /ironFlag flag Also, don’t warn about body-less functions/methods in the parser — this is done by the compiler. * Remove /ironDafny flag from tests * Move a test to wish folder Co-authored-by: David Cok <[email protected]>
1 parent 1f48c75 commit c2c5c2c

File tree

15 files changed

+29
-112
lines changed

15 files changed

+29
-112
lines changed

Source/Dafny/Compiler-Csharp.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,12 +1036,6 @@ protected override string TypeName(Type type, TextWriter wr, Bpl.IToken tok, Mem
10361036
bool isHandle = true;
10371037
if (cl != null && Attributes.ContainsBool(cl.Attributes, "handle", ref isHandle) && isHandle) {
10381038
return "ulong";
1039-
} else if (DafnyOptions.O.IronDafny &&
1040-
!(xType is ArrowType) &&
1041-
cl != null &&
1042-
cl.EnclosingModuleDefinition != null &&
1043-
!cl.EnclosingModuleDefinition.IsDefaultModule) {
1044-
s = cl.FullCompileName;
10451039
}
10461040
return TypeName_UDT(s, udt, wr, udt.tok);
10471041
} else if (xType is SetType) {
@@ -1175,14 +1169,6 @@ protected override string TypeInitializationValue(Type type, TextWriter wr, Bpl.
11751169
}
11761170
} else if (cl is DatatypeDecl dt) {
11771171
var s = FullTypeName(udt);
1178-
var rc = cl;
1179-
if (DafnyOptions.O.IronDafny &&
1180-
!(xType is ArrowType) &&
1181-
rc != null &&
1182-
rc.EnclosingModuleDefinition != null &&
1183-
!rc.EnclosingModuleDefinition.IsDefaultModule) {
1184-
s = "@" + rc.FullCompileName;
1185-
}
11861172
if (udt.TypeArgs.Count != 0) {
11871173
s += "<" + TypeNames(udt.TypeArgs, wr, udt.tok) + ">";
11881174
}

Source/Dafny/Compiler-cpp.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,12 +897,6 @@ protected string TypeName(Type type, TextWriter wr, Bpl.IToken tok, MemberDecl/*
897897
bool isHandle = true;
898898
if (cl != null && Attributes.ContainsBool(cl.Attributes, "handle", ref isHandle) && isHandle) {
899899
return "ulong";
900-
} else if (DafnyOptions.O.IronDafny &&
901-
!(xType is ArrowType) &&
902-
cl != null &&
903-
cl.EnclosingModuleDefinition != null &&
904-
!cl.EnclosingModuleDefinition.IsDefaultModule) {
905-
s = cl.FullCompileName;
906900
}
907901
if (class_name || xType.IsTypeParameter || xType.IsDatatype) { // Don't add pointer decorations to class names or type parameters
908902
return IdProtect(s) + ActualTypeArgs(xType.TypeArgs);

Source/Dafny/Compiler-go.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,12 +1358,6 @@ protected override string TypeName(Type type, TextWriter wr, Bpl.IToken tok, Mem
13581358
bool isHandle = true;
13591359
if (cl != null && Attributes.ContainsBool(cl.Attributes, "handle", ref isHandle) && isHandle) {
13601360
return "ulong";
1361-
} else if (DafnyOptions.O.IronDafny &&
1362-
!(xType is ArrowType) &&
1363-
cl != null &&
1364-
cl.EnclosingModuleDefinition != null &&
1365-
!cl.EnclosingModuleDefinition.IsDefaultModule) {
1366-
s = cl.FullCompileName;
13671361
} else if (xType is ArrowType at) {
13681362
return string.Format("func ({0}) {1}", Util.Comma(at.Args, arg => TypeName(arg, wr, tok)), TypeName(at.Result, wr, tok));
13691363
} else if (cl is TupleTypeDecl) {

Source/Dafny/Dafny.atg

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,7 @@ TopDecl<. ModuleDefinition module, List<MemberDecl/*!*/> membersDefaultClass, bo
901901
| SynonymTypeDecl<dmod, module, out td> (. module.TopLevelDecls.Add(td); .)
902902
| IteratorDecl<dmod, module, out iter> (. module.TopLevelDecls.Add(iter); .)
903903
| TraitDecl<dmod, module, out trait> (. module.TopLevelDecls.Add(trait); .)
904-
| ClassMemberDecl<dmod, membersDefaultClass, false, true, !DafnyOptions.O.AllowGlobals,
905-
!isTopLevel && DafnyOptions.O.IronDafny && isAbstract>
904+
| ClassMemberDecl<dmod, membersDefaultClass, false, true, !DafnyOptions.O.AllowGlobals>
906905
)
907906
.
908907

@@ -1104,7 +1103,7 @@ ClassDecl<DeclModifierData dmodClass, ModuleDefinition/*!*/ module, out TopLevel
11041103
"{" (. bodyStart = t; .)
11051104
{ (. dmod = new DeclModifierData(); .)
11061105
{ DeclModifier<ref dmod> }
1107-
ClassMemberDecl<dmod, members, true, false, false, false>
1106+
ClassMemberDecl<dmod, members, true, false, false>
11081107
}
11091108
"}"
11101109
(. c = new ClassDecl(id, id.val, module, typeArgs, members, attrs, isRefining, parentTraits);
@@ -1141,7 +1140,7 @@ TraitDecl<DeclModifierData dmodIn, ModuleDefinition/*!*/ module, out TraitDecl/*
11411140
"{" (. bodyStart = t; .)
11421141
{ (. dmod = new DeclModifierData(); .)
11431142
{ DeclModifier<ref dmod> }
1144-
ClassMemberDecl<dmod, members, true, false, false, false>
1143+
ClassMemberDecl<dmod, members, true, false, false>
11451144
}
11461145
"}"
11471146
(. trait = new TraitDecl(id, id.val, module, typeArgs, members, attrs, isRefining, parentTraits);
@@ -1151,7 +1150,7 @@ TraitDecl<DeclModifierData dmodIn, ModuleDefinition/*!*/ module, out TraitDecl/*
11511150
.
11521151

11531152
/*------------------------------------------------------------------------*/
1154-
ClassMemberDecl<. DeclModifierData dmod, List<MemberDecl> mm, bool allowConstructors, bool isValueType, bool moduleLevelDecl, bool isWithinAbstractModule.>
1153+
ClassMemberDecl<. DeclModifierData dmod, List<MemberDecl> mm, bool allowConstructors, bool isValueType, bool moduleLevelDecl.>
11551154
= (. Contract.Requires(cce.NonNullElements(mm));
11561155
Method/*!*/ m;
11571156
Function/*!*/ f;
@@ -1169,13 +1168,13 @@ ClassMemberDecl<. DeclModifierData dmod, List<MemberDecl> mm, bool allowConstruc
11691168
dmod.IsStatic = false;
11701169
}
11711170
.)
1172-
FunctionDecl<dmod, isWithinAbstractModule, out f> (. mm.Add(f); .)
1171+
FunctionDecl<dmod, out f> (. mm.Add(f); .)
11731172
| (. if (moduleLevelDecl && dmod.StaticToken != null) {
11741173
errors.Warning(dmod.StaticToken, "module-level methods are always non-instance, so the 'static' keyword is not allowed here");
11751174
dmod.IsStatic = false;
11761175
}
11771176
.)
1178-
MethodDecl<dmod, allowConstructors, isWithinAbstractModule, out m> (. mm.Add(m); .)
1177+
MethodDecl<dmod, allowConstructors, out m> (. mm.Add(m); .)
11791178
)
11801179
.
11811180

@@ -1240,7 +1239,7 @@ TypeMembers<. ModuleDefinition/*!*/ module, List<MemberDecl> members .>
12401239
"{"
12411240
{ (. dmod = new DeclModifierData(); .)
12421241
{ DeclModifier<ref dmod> }
1243-
ClassMemberDecl<dmod, members, false, true, false, module.IsAbstract>
1242+
ClassMemberDecl<dmod, members, false, true, false>
12441243
}
12451244
"}"
12461245
.
@@ -1613,7 +1612,7 @@ TPCharOption<ref TypeParameter.TypeParameterCharacteristics characteristics>
16131612
.
16141613

16151614
/*------------------------------------------------------------------------*/
1616-
MethodDecl<DeclModifierData dmod, bool allowConstructor, bool isWithinAbstractModule, out Method/*!*/ m>
1615+
MethodDecl<DeclModifierData dmod, bool allowConstructor, out Method/*!*/ m>
16171616
= (. Contract.Ensures(Contract.ValueAtReturn(out m) !=null);
16181617
IToken/*!*/ id = Token.NoToken;
16191618
bool hasName = false; IToken keywordToken;
@@ -1697,12 +1696,7 @@ MethodDecl<DeclModifierData dmod, bool allowConstructor, bool isWithinAbstractMo
16971696
(. body = dividedBody; .)
16981697
| BlockStmt<out body, out bodyStart, out bodyEnd>
16991698
]
1700-
(.
1701-
if (!isWithinAbstractModule && DafnyOptions.O.DisallowSoundnessCheating && body == null && ens.Count > 0 && !Attributes.Contains(attrs, "axiom") && !Attributes.Contains(attrs, "imported") && !Attributes.Contains(attrs, "decl") && theVerifyThisFile) {
1702-
SemErr(t, "a method with an ensures clause must have a body, unless given the :axiom attribute");
1703-
}
1704-
1705-
IToken tok = id;
1699+
(. IToken tok = id;
17061700
if (isConstructor) {
17071701
m = new Constructor(tok, hasName ? id.val : "_ctor", typeArgs, ins,
17081702
req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), (DividedBlockStmt)body, attrs, signatureEllipsis);
@@ -2043,7 +2037,7 @@ GenericInstantiation<.List<Type> gt.>
20432037
.
20442038

20452039
/*------------------------------------------------------------------------*/
2046-
FunctionDecl<DeclModifierData dmod, bool isWithinAbstractModule, out Function/*!*/ f>
2040+
FunctionDecl<DeclModifierData dmod, out Function/*!*/ f>
20472041
= (. Contract.Ensures(Contract.ValueAtReturn(out f)!=null);
20482042
Attributes attrs = null;
20492043
IToken/*!*/ id = Token.NoToken; // to please compiler
@@ -2175,11 +2169,7 @@ FunctionDecl<DeclModifierData dmod, bool isWithinAbstractModule, out Function/*!
21752169
FunctionSpec<reqs, reads, ens, decreases>
21762170
[ FunctionBody<out body, out bodyStart, out bodyEnd>
21772171
]
2178-
(. if (!isWithinAbstractModule && DafnyOptions.O.DisallowSoundnessCheating && body == null && ens.Count > 0 &&
2179-
!Attributes.Contains(attrs, "axiom") && !Attributes.Contains(attrs, "imported")) {
2180-
SemErr(t, "a function with an ensures clause must have a body, unless given the :axiom attribute");
2181-
}
2182-
IToken tok = id;
2172+
(. IToken tok = id;
21832173
if (isTwoState && isPredicate) {
21842174
f = new TwoStatePredicate(tok, id.val, dmod.IsStatic, typeArgs, formals,
21852175
reqs, reads, ens, new Specification<Expression>(decreases, null), body, attrs, signatureEllipsis);

Source/Dafny/DafnyOptions.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ public DafnyOptions(ErrorReporter errorReporter = null)
2222

2323
public override string VersionNumber {
2424
get {
25-
return System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion
26-
#if ENABLE_IRONDAFNY
27-
+ "[IronDafny]"
28-
#endif
29-
;
25+
return System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion;
3026
}
3127
}
3228
public override string Version {
@@ -102,13 +98,6 @@ public enum IncludesModes { None, Immediate, Transitive }
10298
public bool UseRuntimeLib = false;
10399
public bool DisableScopes = false;
104100
public int Allocated = 3;
105-
public bool IronDafny =
106-
#if ENABLE_IRONDAFNY
107-
true
108-
#else
109-
false
110-
#endif
111-
;
112101

113102
protected override bool ParseOption(string name, Bpl.CommandLineOptionEngine.CommandLineParseState ps) {
114103
var args = ps.args; // convenient synonym
@@ -354,16 +343,6 @@ protected override bool ParseOption(string name, Bpl.CommandLineOptionEngine.Com
354343
return true;
355344
}
356345

357-
case "noIronDafny": {
358-
IronDafny = false;
359-
return true;
360-
}
361-
362-
case "ironDafny": {
363-
IronDafny = true;
364-
return true;
365-
}
366-
367346
case "optimizeResolution": {
368347
int d = 2;
369348
if (ps.GetNumericArgument(ref d, 3)) {
@@ -844,10 +823,6 @@ even bound variables in quantifiers. This option is
844823
3 - (default) Frugal use of heap parameters.
845824
4 - mode 3 but with alloc antecedents when ranges don't imply
846825
allocatedness.
847-
/ironDafny Enable experimental features needed to support Ironclad/Ironfleet. Use of
848-
these features may cause your code to become incompatible with future
849-
releases of Dafny.
850-
/noIronDafny Disable Ironclad/Ironfleet features, if enabled by default.
851826
/printTooltips
852827
Dump additional positional information (displayed as mouse-over tooltips by
853828
the VS plugin) to stdout as 'Info' messages.

Source/Dafny/Resolver.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,17 +1766,12 @@ static void ResolveOpenedImportsWorker(ModuleSignature sig, ModuleDefinition mod
17661766

17671767
importedSigs.Add(s);
17681768

1769-
if (useImports || DafnyOptions.O.IronDafny) {
1769+
if (useImports) {
17701770
// classes:
17711771
foreach (var kv in s.TopLevels) {
17721772
if (!kv.Value.CanBeExported())
17731773
continue;
17741774

1775-
if (kv.Value is ModuleDecl && ((ModuleDecl)kv.Value).Opened && DafnyOptions.O.IronDafny) {
1776-
ResolveOpenedImportsWorker(sig, moduleDef, (ModuleDecl)kv.Value, importedSigs, useCompileSignatures);
1777-
}
1778-
1779-
// IronDafny: we need to pull the members of the opened module's _default class in so that they can be merged.
17801775
if (useImports || string.Equals(kv.Key, "_default", StringComparison.InvariantCulture)) {
17811776
TopLevelDecl d;
17821777
if (sig.TopLevels.TryGetValue(kv.Key, out d)) {
@@ -1823,7 +1818,7 @@ static void ResolveOpenedImportsWorker(ModuleSignature sig, ModuleDefinition mod
18231818
}
18241819
}
18251820

1826-
if (useImports || DafnyOptions.O.IronDafny) {
1821+
if (useImports) {
18271822
// static members:
18281823
foreach (var kv in s.StaticMembers) {
18291824
if (!kv.Value.CanBeExported())

Source/Dafny/Translator.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15341,11 +15341,7 @@ public Bpl.Expr TrExpr(Expression expr) {
1534115341
}
1534215342

1534315343
var ty = translator.TrType(e.Type);
15344-
var name = e.Function.FullSanitizedName;
15345-
if (DafnyOptions.O.IronDafny) {
15346-
name = e.Function.FullSanitizedRefinementName;
15347-
}
15348-
var id = new Bpl.IdentifierExpr(e.tok, name, ty);
15344+
var id = new Bpl.IdentifierExpr(e.tok, e.Function.FullSanitizedName, ty);
1534915345

1535015346
bool argsAreLit;
1535115347
var args = FunctionInvocationArguments(e, layerArgument, false, out argsAreLit);
@@ -17305,11 +17301,6 @@ Bpl.Trigger TrTrigger(ExpressionTranslator etran, Attributes attribs, IToken tok
1730517301

1730617302
bool useFuelAsQuantifier = argsEtran.Statistics_CustomLayerFunctionCount > 0;
1730717303
bool useHeapAsQuantifier = argsEtran.Statistics_HeapAsQuantifierCount > 0;
17308-
Expr qly = null;
17309-
if (useFuelAsQuantifier && DafnyOptions.O.IronDafny) {
17310-
qly = BplBoundVar(CurrentIdGenerator.FreshId("tr$ly#"), predef.LayerType, bvars);
17311-
argsEtran = argsEtran.WithLayer(qly);
17312-
}
1731317304
if (useHeapAsQuantifier) {
1731417305
var heapExpr = BplBoundVar(CurrentIdGenerator.FreshId("tr$heap#"), predef.HeapType, bvars);
1731517306
argsEtran = new ExpressionTranslator(argsEtran, heapExpr);
@@ -17328,11 +17319,6 @@ Bpl.Trigger TrTrigger(ExpressionTranslator etran, Attributes attribs, IToken tok
1732817319
if (useHeapAsQuantifier) {
1732917320
tt.Add(FunctionCall(tok, BuiltinFunction.IsGoodHeap, null, argsEtran.HeapExpr));
1733017321
}
17331-
if (useFuelAsQuantifier && !fueledTrigger[trigger.Args] && DafnyOptions.O.IronDafny) {
17332-
// We quantified over fuel, but this particular trigger doesn't use it,
17333-
// so we need to add a dummy trigger. Hopefully it will always be in scope when needed.
17334-
tt.Add(FunctionCall(tok, BuiltinFunction.AsFuelBottom, null, qly));
17335-
}
1733617322
tr = new Bpl.Trigger(tok, true, tt, tr);
1733717323
}
1733817324
return tr;

Test/allocated1/dafny0/FuelTriggers.dfy

Lines changed: 0 additions & 3 deletions
This file was deleted.

Test/allocated1/dafny0/FuelTriggers.dfy.expect

Lines changed: 0 additions & 2 deletions
This file was deleted.

Test/dafny0/FuelTriggers.dfy.expect

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)