diff --git a/Source/DafnyCore/AST/Cloner.cs b/Source/DafnyCore/AST/Cloner.cs index 6a8c76b5634..c876a793602 100644 --- a/Source/DafnyCore/AST/Cloner.cs +++ b/Source/DafnyCore/AST/Cloner.cs @@ -260,6 +260,9 @@ public virtual Type CloneType(Type t) { } else if (t is TypeRefinementWrapper typeRefinementWrapper) { // don't bother keeping TypeRefinementWrapper wrappers return CloneType(typeRefinementWrapper.T); + } else if (t is BottomTypePlaceholder bottomTypePlaceholder) { + // don't bother keeping BottomTypePlaceholder wrappers + return CloneType(bottomTypePlaceholder.T); } else { Contract.Assert(false); // unexpected type (e.g., no other type proxies are expected at this time) return null; // to please compiler diff --git a/Source/DafnyCore/AST/Modules/ModuleDefinition.cs b/Source/DafnyCore/AST/Modules/ModuleDefinition.cs index c604abdc537..c42e9d9fca7 100644 --- a/Source/DafnyCore/AST/Modules/ModuleDefinition.cs +++ b/Source/DafnyCore/AST/Modules/ModuleDefinition.cs @@ -315,6 +315,14 @@ public static IEnumerable AllFields(IEnumerable declaration } } + public static IEnumerable AllMembers(IEnumerable declarations) { + foreach (var decl in declarations.OfType()) { + foreach (var member in decl.Members) { + yield return member; + } + } + } + public static IEnumerable AllTypesWithMembers(List declarations) { foreach (var d in declarations) { if (d is TopLevelDeclWithMembers cl) { @@ -905,7 +913,9 @@ public ModuleSignature RegisterTopLevelDecls(ModuleResolver resolver, bool useIm } } - ctor.Destructors.Add(dtor); + if (!localDuplicate) { + ctor.Destructors.Add(dtor); + } } foreach (var duplicate in duplicates) { diff --git a/Source/DafnyCore/AST/SystemModuleManager.cs b/Source/DafnyCore/AST/SystemModuleManager.cs index 2c8c02fa49f..233b2e949c4 100644 --- a/Source/DafnyCore/AST/SystemModuleManager.cs +++ b/Source/DafnyCore/AST/SystemModuleManager.cs @@ -72,6 +72,7 @@ public byte[] MyHash { public readonly ISet Bitwidths = new HashSet(); [FilledInDuringResolution] public SpecialField ORDINAL_Offset; // used by the translator + public readonly TypeSynonymDecl StringDecl; public readonly SubsetTypeDecl NatDecl; public UserDefinedType Nat() { return new UserDefinedType(Token.NoToken, "nat", NatDecl, new List()); } public readonly TraitDecl ObjectDecl; @@ -92,10 +93,10 @@ public SystemModuleManager(DafnyOptions options) { this.Options = options; SystemModule.Height = -1; // the system module doesn't get a height assigned later, so we set it here to something below everything else // create type synonym 'string' - var str = new TypeSynonymDecl(SourceOrigin.NoToken, new Name("string"), + StringDecl = new TypeSynonymDecl(SourceOrigin.NoToken, new Name("string"), new TypeParameter.TypeParameterCharacteristics(TypeParameter.EqualitySupportValue.InferredRequired, Type.AutoInitInfo.CompilableValue, false), new List(), SystemModule, new SeqType(new CharType()), null); - SystemModule.SourceDecls.Add(str); + SystemModule.SourceDecls.Add(StringDecl); // create subset type 'nat' var bvNat = new BoundVar(Token.NoToken, "x", Type.Int); var natConstraint = Expression.CreateAtMost(Expression.CreateIntLiteral(Token.NoToken, 0), Expression.CreateIdentExpr(bvNat)); diff --git a/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs b/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs index 31af8d68bcb..c5ca9e5b3c8 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs @@ -16,6 +16,10 @@ void ObjectInvariant() { public IOrigin BodyStartTok = Token.NoToken; public Name NameNode; + public string GetNameRelativeToModule() { + return this is ICallable iCallable ? iCallable.NameRelativeToModule : ToString(); + } + public virtual IOrigin NavigationToken => NameNode.Origin; public string Name => NameNode.Value; @@ -150,4 +154,4 @@ public override string ToString() { // For Compilation internal CodeGenIdGenerator CodeGenIdGenerator = new(); -} \ No newline at end of file +} diff --git a/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs b/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs index d8092b84678..61641c5fa3f 100644 --- a/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs +++ b/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs @@ -3366,7 +3366,8 @@ protected override void EmitConversionExpr(Expression fromExpr, Type fromType, T } else if (fromType.Equals(toType) || fromType.AsNewtype != null || toType.AsNewtype != null) { wr.Append(Expr(fromExpr, inLetExprBody, wStmts)); } else { - Contract.Assert(false, $"not implemented for C#: {fromType} -> {toType}"); + wr = EmitDowncast(fromType, toType, fromExpr.Origin, wr); + EmitExpr(fromExpr, inLetExprBody, wr, wStmts); } } diff --git a/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs b/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs index 12dfa815b05..e2579794a0b 100644 --- a/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs +++ b/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs @@ -3794,7 +3794,8 @@ protected override void EmitConversionExpr(Expression fromExpr, Type fromType, T } else if (fromType.Equals(toType) || fromType.AsNewtype != null || toType.AsNewtype != null) { wr.Append(Expr(fromExpr, inLetExprBody, wStmts)); } else { - Contract.Assert(false, $"not implemented for go: {fromType} -> {toType}"); + wr = EmitCoercionIfNecessary(fromType, toType, fromExpr.Origin, wr); + EmitExpr(fromExpr, inLetExprBody, wr, wStmts); } } diff --git a/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs b/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs index 89c86b482ad..5e3c27b8e70 100644 --- a/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs +++ b/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs @@ -4249,7 +4249,8 @@ protected override void EmitConversionExpr(Expression fromExpr, Type fromType, T } else if (fromType.Equals(toType) || fromType.AsNewtype != null || toType.AsNewtype != null) { wr.Append(Expr(fromExpr, inLetExprBody, wStmts)); } else { - Contract.Assert(false, $"not implemented for java: {fromType} -> {toType}"); + wr = EmitDowncast(fromType, toType, fromExpr.Origin, wr); + EmitExpr(fromExpr, inLetExprBody, wr, wStmts); } } diff --git a/Source/DafnyCore/Backends/JavaScript/JavaScriptCodeGenerator.cs b/Source/DafnyCore/Backends/JavaScript/JavaScriptCodeGenerator.cs index a75fd312f41..37fce4ea43e 100644 --- a/Source/DafnyCore/Backends/JavaScript/JavaScriptCodeGenerator.cs +++ b/Source/DafnyCore/Backends/JavaScript/JavaScriptCodeGenerator.cs @@ -2464,7 +2464,7 @@ protected override void EmitConversionExpr(Expression fromExpr, Type fromType, T } else if (fromType.Equals(toType) || fromType.AsNewtype != null || toType.AsNewtype != null) { wr.Append(Expr(fromExpr, inLetExprBody, wStmts)); } else { - Contract.Assert(false, $"not implemented for javascript: {fromType} -> {toType}"); + EmitExpr(fromExpr, inLetExprBody, wr, wStmts); } } diff --git a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs index c500840ef55..3d01d2894a3 100644 --- a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs +++ b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs @@ -4547,9 +4547,9 @@ protected virtual void TrCallStmt(CallStmt s, string receiverReplacement, Concre if (!p.IsGhost) { wr.Write(sep); var fromType = s.Args[i].Type; - var toType = s.Method.Ins[i].Type; - var instantiatedToType = toType.Subst(s.MethodSelect.TypeArgumentSubstitutionsWithParents()); - var w = EmitCoercionIfNecessary(fromType, instantiatedToType, s.Origin, wr, toType); + var origToType = s.Method.Original.Ins[i].Type; + var instantiatedToType = origToType.Subst(s.MethodSelect.TypeArgumentSubstitutionsWithParents()); + var w = EmitCoercionIfNecessary(fromType, instantiatedToType, s.Origin, wr, origToType); w = EmitDowncastIfNecessary(fromType, instantiatedToType, s.Origin, w); EmitExpr(s.Args[i], false, w, wStmts); sep = ", "; @@ -5325,7 +5325,7 @@ protected virtual void CompileFunctionCallExpr(FunctionCallExpr e, ConcreteSynta wr.Write(sep); var fromType = e.Args[i].Type; var instantiatedToType = e.Function.Ins[i].Type.Subst(e.TypeArgumentSubstitutionsWithParents()); - var w = EmitCoercionIfNecessary(fromType, instantiatedToType, tok: e.Origin, wr: wr, e.Function.Ins[i].Type); + var w = EmitCoercionIfNecessary(fromType, instantiatedToType, tok: e.Origin, wr: wr, e.Function.Original.Ins[i].Type); w = EmitDowncastIfNecessary(fromType, instantiatedToType, e.Origin, w); tr(e.Args[i], w, inLetExprBody, wStmts); sep = ", "; diff --git a/Source/DafnyCore/CompileNestedMatch/MatchFlattener.cs b/Source/DafnyCore/CompileNestedMatch/MatchFlattener.cs index ebb7252d4fa..eecf163f37e 100644 --- a/Source/DafnyCore/CompileNestedMatch/MatchFlattener.cs +++ b/Source/DafnyCore/CompileNestedMatch/MatchFlattener.cs @@ -160,12 +160,12 @@ private ExtendedPattern RemoveIllegalSubpatterns(ExtendedPattern pat, bool inDis return pat; case IdPattern p: if (inDisjunctivePattern && p.ResolvedLit == null && p.Arguments == null && !p.IsWildcardPattern) { - return new IdPattern(p.Origin, FreshTempVarName("_", null), null, p.IsGhost); + return new IdPattern(p.Origin, "_", null, p.IsGhost); } var args = p.Arguments?.ConvertAll(a => RemoveIllegalSubpatterns(a, inDisjunctivePattern)); return new IdPattern(p.Origin, p.Id, p.Type, args, p.IsGhost) { ResolvedLit = p.ResolvedLit, BoundVar = p.BoundVar }; case DisjunctivePattern p: - return new IdPattern(p.Origin, FreshTempVarName("_", null), null, p.IsGhost); + return new IdPattern(p.Origin, "_", null, p.IsGhost); default: Contract.Assert(false); return null; diff --git a/Source/DafnyCore/DafnyMain.cs b/Source/DafnyCore/DafnyMain.cs index a7a149b0d1d..7a6928f57c3 100644 --- a/Source/DafnyCore/DafnyMain.cs +++ b/Source/DafnyCore/DafnyMain.cs @@ -87,10 +87,6 @@ public static string Resolve(Program program) { return null; } - if (program.Options.Get(CommonOptionBag.GeneralNewtypes) && !program.Options.Get(CommonOptionBag.TypeSystemRefresh)) { - return "use of --general-newtypes requires --type-system-refresh"; - } - var programResolver = new ProgramResolver(program); #pragma warning disable VSTHRD002 LargeStackFactory.StartNew(() => programResolver.Resolve(CancellationToken.None)).Wait(); diff --git a/Source/DafnyCore/Generic/ErrorReporter.cs b/Source/DafnyCore/Generic/ErrorReporter.cs index 03d44d0150b..bf692662480 100644 --- a/Source/DafnyCore/Generic/ErrorReporter.cs +++ b/Source/DafnyCore/Generic/ErrorReporter.cs @@ -70,7 +70,7 @@ public void Error(MessageSource source, Enum errorId, IOrigin tok, string format Contract.Requires(tok != null); Contract.Requires(format != null); Contract.Requires(args != null); - Error(source, errorId.ToString(), tok, string.Format(format, args)); + Error(source, errorId.ToString(), tok, Format(format, args)); } public void Error(MessageSource source, Enum errorId, IOrigin tok, string msg) { @@ -139,7 +139,7 @@ public void Warning(MessageSource source, Enum errorId, IOrigin tok, string form Contract.Requires(tok != null); Contract.Requires(format != null); Contract.Requires(args != null); - Warning(source, errorId, tok, String.Format(format, args)); + Warning(source, errorId, tok, Format(format, args)); } public void Warning(MessageSource source, Enum errorId, IOrigin tok, string msg) { @@ -179,7 +179,7 @@ public void Deprecated(MessageSource source, Enum errorId, IOrigin tok, string f Contract.Requires(format != null); Contract.Requires(args != null); if (Options.DeprecationNoise != 0) { - Warning(source, errorId, tok, String.Format(format, args)); + Warning(source, errorId, tok, Format(format, args)); } } @@ -189,14 +189,22 @@ public void Info(MessageSource source, IOrigin tok, string msg, object errorId = Message(source, ErrorLevel.Info, errorId?.ToString(), tok, msg); } - public void Info(MessageSource source, IOrigin tok, string msg, params object[] args) { + public void Info(MessageSource source, IOrigin tok, string format, params object[] args) { Contract.Requires(tok != null); - Contract.Requires(msg != null); + Contract.Requires(format != null); Contract.Requires(args != null); - Info(source, tok, String.Format(msg, args)); + Info(source, tok, Format(format, args)); + } + + private string Format(string format, object[] args) { + // In some cases, the "format" isn't actually a (Dafny-generated) format string, but a (user-defined) literal string. + // Such a user-defined literal may contain format information, like the "{0}" in the "ensures x in {0} <==> x in {1}". + // To prevent such string from going to string.Format, we first check if "args" has any arguments at all. + // This solves all known issues. + return args.Length == 0 ? format : string.Format(format, args); } public string ErrorToString(ErrorLevel header, IOrigin tok, string msg) { return $"{tok.TokenToString(Options)}: {header.ToString()}: {msg}"; } -} \ No newline at end of file +} diff --git a/Source/DafnyCore/Options/CommonOptionBag.cs b/Source/DafnyCore/Options/CommonOptionBag.cs index 8ade67e6e07..11de8c3b19a 100644 --- a/Source/DafnyCore/Options/CommonOptionBag.cs +++ b/Source/DafnyCore/Options/CommonOptionBag.cs @@ -210,10 +210,10 @@ Note that quantifier variable domains (<- ) are available in both syntax "Prevents a warning from being generated for axioms, such as assume statements and functions or methods without a body, that don't have an {:axiom} attribute.") { }; - public static readonly Option TypeSystemRefresh = new("--type-system-refresh", () => false, + public static readonly Option TypeSystemRefresh = new("--type-system-refresh", () => true, @" false - The type-inference engine and supported types are those of Dafny 4.0. -true - Use an updated type-inference engine.".TrimStart()) { +true (default) - Use an updated type-inference engine.".TrimStart()) { IsHidden = true }; @@ -223,18 +223,18 @@ public enum GeneralTraitsOptions { Full } - public static readonly Option GeneralTraits = new("--general-traits", () => GeneralTraitsOptions.Legacy, + public static readonly Option GeneralTraits = new("--general-traits", () => GeneralTraitsOptions.Datatype, @" legacy - Every trait implicitly extends 'object', and thus is a reference type. Only traits and reference types can extend traits. -datatype - A trait is a reference type only if it or one of its ancestor traits is 'object'. Any non-'newtype' type with members can extend traits. +datatype (default) - A trait is a reference type only if it or one of its ancestor traits is 'object'. Any non-'newtype' type with members can extend traits. full - (don't use; not yet completely supported) A trait is a reference type only if it or one of its ancestor traits is 'object'. Any type with members can extend traits.".TrimStart()) { IsHidden = true }; - public static readonly Option GeneralNewtypes = new("--general-newtypes", () => false, + public static readonly Option GeneralNewtypes = new("--general-newtypes", () => true, @" false - A newtype can only be based on numeric types or another newtype. -true - (requires --type-system-refresh) A newtype case be based on any non-reference, non-trait, non-arrow, non-ORDINAL type.".TrimStart()) { +true (default) - (requires --type-system-refresh) A newtype case be based on any non-reference, non-trait, non-arrow, non-ORDINAL type.".TrimStart()) { IsHidden = true }; @@ -434,15 +434,16 @@ datatype with a single non-ghost constructor that has a single 0 - The char type represents any UTF-16 code unit. 1 (default) - The char type represents any Unicode scalar value.".TrimStart(), defaultValue: true); DafnyOptions.RegisterLegacyUi(TypeSystemRefresh, DafnyOptions.ParseBoolean, "Language feature selection", "typeSystemRefresh", @" -0 (default) - The type-inference engine and supported types are those of Dafny 4.0. -1 - Use an updated type-inference engine. Warning: This mode is under construction and probably won't work at this time.".TrimStart(), defaultValue: false); +0 - The type-inference engine and supported types are those of Dafny 4.0. +1 (default) - Use an updated type-inference engine.".TrimStart(), defaultValue: true); DafnyOptions.RegisterLegacyUi(GeneralTraits, DafnyOptions.ParseGeneralTraitsOption, "Language feature selection", "generalTraits", @" -legacy (default) - Every trait implicitly extends 'object', and thus is a reference type. Only traits and reference types can extend traits. -datatype - A trait is a reference type only if it or one of its ancestor traits is 'object'. Any non-'newtype' type with members can extend traits. -full - (don't use; not yet completely supported) A trait is a reference type only if it or one of its ancestor traits is 'object'. Any type with members can extend traits.".TrimStart()); +legacy - Every trait implicitly extends 'object', and thus is a reference type. Only traits and reference types can extend traits. +datatype (default) - A trait is a reference type only if it or one of its ancestor traits is 'object'. Any non-'newtype' type with members can extend traits. +full - (don't use; not yet completely supported) A trait is a reference type only if it or one of its ancestor traits is 'object'. Any type with members can extend traits.".TrimStart(), + defaultValue: GeneralTraitsOptions.Datatype); DafnyOptions.RegisterLegacyUi(GeneralNewtypes, DafnyOptions.ParseBoolean, "Language feature selection", "generalNewtypes", @" -0 (default) - A newtype can only be based on numeric types or another newtype. -1 - (requires /typeSystemRefresh:1) A newtype case be based on any non-reference, non-trait, non-arrow, non-ORDINAL type.".TrimStart(), false); +0 - A newtype can only be based on numeric types or another newtype. +1 (default) - (requires /typeSystemRefresh:1) A newtype case be based on any non-reference, non-trait, non-arrow, non-ORDINAL type.".TrimStart(), true); DafnyOptions.RegisterLegacyUi(TypeInferenceDebug, DafnyOptions.ParseBoolean, "Language feature selection", "titrace", @" 0 (default) - Don't print type-inference debug information. 1 - Print type-inference debug information.".TrimStart(), defaultValue: false); diff --git a/Source/DafnyCore/Resolver/ModuleResolver.cs b/Source/DafnyCore/Resolver/ModuleResolver.cs index 0aa3a165156..b2fbeb3d069 100644 --- a/Source/DafnyCore/Resolver/ModuleResolver.cs +++ b/Source/DafnyCore/Resolver/ModuleResolver.cs @@ -1127,6 +1127,11 @@ public void ResolveTopLevelDecls_Core(List declarations, int prevErrorCount = reporter.Count(ErrorLevel.Error); + if (Options.Get(CommonOptionBag.GeneralNewtypes) && !Options.Get(CommonOptionBag.TypeSystemRefresh)) { + reporter.Error(MessageSource.Resolver, Token.NoToken, "use of --general-newtypes requires --type-system-refresh"); + return; + } + // ---------------------------------- Pass 0 ---------------------------------- // This pass: // * resolves names, introduces (and may solve) type constraints @@ -1477,6 +1482,17 @@ public void ResolveTopLevelDecls_Core(List declarations, } } + foreach (var member in ModuleDefinition.AllMembers(declarations)) { + if (member.HasUserAttribute("only", out var attribute)) { + reporter.Warning(MessageSource.Verifier, ResolutionErrors.ErrorId.r_member_only_assumes_other.ToString(), attribute.Origin, + "Members with {:only} temporarily disable the verification of other members in the entire file"); + if (attribute.Args.Count >= 1) { + reporter.Warning(MessageSource.Verifier, ResolutionErrors.ErrorId.r_member_only_has_no_before_after.ToString(), attribute.Args[0].Origin, + "{:only} on members does not support arguments"); + } + } + } + if (reporter.Count(ErrorLevel.Error) == prevErrorCount) { // Check that class constructors are called when required. new ObjectConstructorChecker(reporter).VisitDeclarations(declarations); @@ -2159,7 +2175,7 @@ public void RegisterInheritedMembers(TopLevelDeclWithMembers cl, [CanBeNull] DPr if (cl is NewtypeDecl newtypeDecl) { if (Options.Get(CommonOptionBag.TypeSystemRefresh)) { baseTypeDecl = basePreType?.Decl as TopLevelDeclWithMembers; - baseTypeArguments = basePreType?.Arguments.ConvertAll(preType => PreType2TypeUtil.PreType2Type(preType, false, TypeParameter.TPVariance.Co)); + baseTypeArguments = basePreType?.Arguments.ConvertAll(preType => PreType2TypeUtil.PreType2Type(preType, false)); } else { // ignore any subset types, since they have no members and thus we don't need their type-parameter mappings var baseType = newtypeDecl.BaseType.NormalizeExpand(); diff --git a/Source/DafnyCore/Resolver/NameResolutionAndTypeInference/NameResolutionAndTypeInference.cs b/Source/DafnyCore/Resolver/NameResolutionAndTypeInference/NameResolutionAndTypeInference.cs index ac71d0f166d..b09791d32a8 100644 --- a/Source/DafnyCore/Resolver/NameResolutionAndTypeInference/NameResolutionAndTypeInference.cs +++ b/Source/DafnyCore/Resolver/NameResolutionAndTypeInference/NameResolutionAndTypeInference.cs @@ -5151,7 +5151,7 @@ private Expression DesugarDatatypeUpdate(IOrigin tok, Expression root, DatatypeD if (candidateResultCtors.Count == 0) { return root; } - Expression rewrite = null; + // Create a unique name for d', the variable we introduce in the let expression var dName = FreshTempVarName("dt_update_tmp#", resolutionContext.CodeContext); var dVar = new BoundVar(new AutoGeneratedOrigin(tok), dName, root.Type); @@ -5160,7 +5160,6 @@ private Expression DesugarDatatypeUpdate(IOrigin tok, Expression root, DatatypeD candidateResultCtors.Reverse(); foreach (var crc in candidateResultCtors) { // Build the arguments to the datatype constructor, using the updated value in the appropriate slot - var ctorArguments = new List(); var actualBindings = new List(); foreach (var f in crc.Formals) { Expression ctorArg; @@ -5169,7 +5168,6 @@ private Expression DesugarDatatypeUpdate(IOrigin tok, Expression root, DatatypeD } else { ctorArg = new ExprDotName(tok, d, f.NameNode, null); } - ctorArguments.Add(ctorArg); var bindingName = new Token(tok.line, tok.col) { Uri = tok.Uri, val = f.Name @@ -5191,7 +5189,7 @@ private Expression DesugarDatatypeUpdate(IOrigin tok, Expression root, DatatypeD Contract.Assert(body != null); // because there was at least one element in candidateResultCtors // Wrap the let's around body - rewrite = body; + var rewrite = body; foreach (var entry in rhsBindings) { if (entry.Value.Item1 != null) { var lhs = new CasePattern(tok, entry.Value.Item1); diff --git a/Source/DafnyCore/Resolver/PreType/PreType.cs b/Source/DafnyCore/Resolver/PreType/PreType.cs index 2bea60dc923..7e90825d966 100644 --- a/Source/DafnyCore/Resolver/PreType/PreType.cs +++ b/Source/DafnyCore/Resolver/PreType/PreType.cs @@ -40,6 +40,7 @@ public abstract class PreType { public const string TypeNameImap = "imap"; public const string TypeNameObjectQ = "object?"; public const string TypeNameArray = "array"; + public const string TypeNameString = "string"; public static string SetTypeName(bool finite) => finite ? TypeNameSet : TypeNameIset; public static string MapTypeName(bool finite) => finite ? TypeNameMap : TypeNameImap; @@ -402,6 +403,17 @@ public override PreType Substitute(Dictionary subst) { return new DPreType(Decl, newArguments ?? Arguments, printablePreType); } + public TopLevelDecl DeclWithMembersBypassInternalSynonym() { + if (Decl is InternalTypeSynonymDecl isyn) { + var udt = UserDefinedType.FromTopLevelDecl(isyn.Origin, isyn); + if (isyn.RhsWithArgumentIgnoringScope(udt.TypeArgs) is UserDefinedType { ResolvedClass: { } decl }) { + return decl is NonNullTypeDecl nntd ? nntd.Class : decl; + } + } + + return Decl; + } + /// /// Returns the pre-type "parent", where "X" is a list of type parameters that makes "parent" a supertype of "this". /// Requires "this" to be some pre-type "C" and "parent" to be among the reflexive, transitive parent traits of "C". @@ -426,7 +438,6 @@ public DPreType AsParentType(TopLevelDecl parent, PreTypeResolver preTypeResolve Contract.Assert(isyn.TypeArgs.Count == cl.TypeArgs.Count); for (var i = 0; i < isyn.TypeArgs.Count; i++) { var typeParameter = isyn.TypeArgs[i]; - Contract.Assert(typeParameter == cl.TypeArgs[i]); Contract.Assert(rhsType.TypeArgs[i] is UserDefinedType { ResolvedClass: var tpDecl } && tpDecl == typeParameter); } diff --git a/Source/DafnyCore/Resolver/PreType/PreType2TypeUtil.cs b/Source/DafnyCore/Resolver/PreType/PreType2TypeUtil.cs index a18ebf80951..b8f657344d8 100644 --- a/Source/DafnyCore/Resolver/PreType/PreType2TypeUtil.cs +++ b/Source/DafnyCore/Resolver/PreType/PreType2TypeUtil.cs @@ -12,42 +12,35 @@ namespace Microsoft.Dafny; public static class PreType2TypeUtil { - public static Type PreType2Type(PreType preType, bool allowFutureRefinements, TypeParameter.TPVariance futureRefinements) { + public static Type PreType2Type(PreType preType, bool allowFutureRefinements) { if (allowFutureRefinements) { - return PreType2RefinableType(preType, futureRefinements); + return PreType2RefinableType(preType); } else { return PreType2FixedType(preType); } } public static Type PreType2FixedType(PreType preType) { - return PreType2TypeCore(preType, false, TypeParameter.TPVariance.Co); + return PreType2TypeCore(preType, false); } - public static Type PreType2RefinableType(PreType preType, TypeParameter.TPVariance futureRefinements) { - var ty = PreType2TypeCore(preType, true, futureRefinements); - switch (futureRefinements) { - case TypeParameter.TPVariance.Co: - ty = new BottomTypePlaceholder(ty); - break; - default: - break; - } - + public static Type PreType2RefinableType(PreType preType) { + var ty = PreType2TypeCore(preType, true); + ty = new BottomTypePlaceholder(ty); return new TypeRefinementWrapper(ty); } /// /// The "futureRefinements" parameter is relevant only if "allowFutureRefinements" is "true". /// - private static Type PreType2TypeCore(PreType preType, bool allowFutureRefinements, TypeParameter.TPVariance futureRefinements) { + private static Type PreType2TypeCore(PreType preType, bool allowFutureRefinements) { var pt = (DPreType)preType.Normalize(); // all pre-types should have been filled in and resolved to a non-proxy if (pt.PrintablePreType != null) { pt = pt.PrintablePreType; } Type ArgumentAsCo(int i) { - return PreType2Type(pt.Arguments[i], true, futureRefinements); + return PreType2Type(pt.Arguments[i], true); } switch (pt.Decl.Name) { @@ -77,7 +70,7 @@ Type ArgumentAsCo(int i) { break; } - var arguments = pt.Arguments.ConvertAll(preType => PreType2RefinableType(preType, futureRefinements)); + var arguments = pt.Arguments.ConvertAll(preType => PreType2RefinableType(preType)); if (pt.Decl is ArrowTypeDecl arrowTypeDecl) { return new ArrowType(pt.Decl.Origin, arrowTypeDecl, arguments); } else if (pt.Decl is ValuetypeDecl valuetypeDecl) { @@ -90,7 +83,7 @@ Type ArgumentAsCo(int i) { } public static void Combine(Type userSuppliedType, PreType preType, bool allowFutureRefinements) { - var preTypeConverted = PreType2Type(preType, allowFutureRefinements, TypeParameter.TPVariance.Co); + var preTypeConverted = PreType2Type(preType, allowFutureRefinements); Combine(userSuppliedType, preTypeConverted); } @@ -106,7 +99,7 @@ public static List Combine([CanBeNull] List types, List pre Contract.Requires(types == null || types.Count == preTypes.Count); if (types == null) { if (allowFutureRefinements) { - return preTypes.ConvertAll(preType => PreType2RefinableType(preType, TypeParameter.TPVariance.Co)); + return preTypes.ConvertAll(preType => PreType2RefinableType(preType)); } else { return preTypes.ConvertAll(PreType2FixedType); } diff --git a/Source/DafnyCore/Resolver/PreType/PreTypeConstraints.cs b/Source/DafnyCore/Resolver/PreType/PreTypeConstraints.cs index f0e718d3ce1..b74464f2146 100644 --- a/Source/DafnyCore/Resolver/PreType/PreTypeConstraints.cs +++ b/Source/DafnyCore/Resolver/PreType/PreTypeConstraints.cs @@ -25,7 +25,7 @@ public class PreTypeConstraints { private Queue equalityConstraints = new(); private List> guardedConstraints = new(); private readonly List defaultAdvice = new(); - private readonly List<(PreTypeProxy, PreType)> compatibleBounds = new(); + private List<(PreTypeProxy, PreType)> compatibleBounds = new(); private List confirmations = new(); public PreTypeConstraints(PreTypeResolver preTypeResolver) { @@ -169,6 +169,8 @@ private bool TryMakeDecisions() { return true; } else if (TryUseCompatibleTypesAsBounds()) { return true; + } else if (TryEquateBounds()) { + return true; } return false; } @@ -348,6 +350,27 @@ bool TryResolveTypeProxiesUsingKnownBounds(bool fromSubBounds, bool ignoreUnknow return anythingChanged; } + /// + /// For any bound ?x :> ?y, equate ?x and ?y. + /// + bool TryEquateBounds() { + var anythingChanged = false; + var constraints = unnormalizedSubtypeConstraints; + unnormalizedSubtypeConstraints = new(); + foreach (var constraint in constraints) { + if (constraint.Super.Normalize() is PreTypeProxy super && constraint.Sub.Normalize() is PreTypeProxy sub) { + if (super != sub) { + super.Set(sub); + anythingChanged = true; + } + } else { + unnormalizedSubtypeConstraints.Add(constraint); + } + } + + return anythingChanged; + } + public static TopLevelDecl/*?*/ JoinHeads(TopLevelDecl a, TopLevelDecl b, SystemModuleManager systemModuleManager) { var aAncestors = new HashSet(); var bAncestors = new HashSet(); @@ -526,13 +549,24 @@ bool TryApplyDefaultAdviceFor(PreTypeProxy proxy) { } bool TryUseCompatibleTypesAsBounds() { + if (compatibleBounds.Count == 0) { + // common special case + return false; + } + var bounds = compatibleBounds; + compatibleBounds = new(); + // if there is a compatible-types constraint "ty ~~ proxy", then decide on the bound "ty :> proxy" bool anythingChanged = false; - foreach (var (compatibleBoundsProxy, compatibleBoundsType) in compatibleBounds) { - if (compatibleBoundsProxy.Normalize() is PreTypeProxy proxy && compatibleBoundsType.Normalize() is DPreType dPreType) { - // make a decision to set this proxy - proxy.Set(dPreType); - anythingChanged = true; + foreach (var item in bounds) { + var (compatibleBoundsProxy, compatibleBoundsType) = item; + if (compatibleBoundsProxy.Normalize() is PreTypeProxy proxy) { + if (!compatibleBoundsType.Contains(proxy, 1, new HashSet(), this, 0)) { + proxy.Set(compatibleBoundsType); + anythingChanged = true; + } + } else { + compatibleBounds.Add(item); } } return anythingChanged; @@ -853,4 +887,4 @@ public void DebugPrint(string format, params object[] args) { } } -} \ No newline at end of file +} diff --git a/Source/DafnyCore/Resolver/PreType/PreTypeResolve.Expressions.cs b/Source/DafnyCore/Resolver/PreType/PreTypeResolve.Expressions.cs index 9f247883582..d0d2694cba9 100644 --- a/Source/DafnyCore/Resolver/PreType/PreTypeResolve.Expressions.cs +++ b/Source/DafnyCore/Resolver/PreType/PreTypeResolve.Expressions.cs @@ -31,7 +31,9 @@ public void ResolveExpression(Expression expr, ResolutionContext resolutionConte case ParensExpression expression: { var e = expression; ResolveExpression(e.E, resolutionContext); - e.ResolvedExpression = e.E; + var innerOrigin = e.E.Origin; + e.ResolvedExpression = e.E; // Overwrites the range, which is not suitable for ParensExpressions + e.E.SetOrigin(innerOrigin); e.PreType = e.E.PreType; break; } @@ -70,9 +72,9 @@ public void ResolveExpression(Expression expr, ResolutionContext resolutionConte } else if (e.Value is BaseTypes.BigDec) { e.PreType = CreatePreTypeProxy($"real literal '{e.Value}'"); Constraints.AddDefaultAdvice(e.PreType, CommonAdvice.Target.Real); - AddConfirmation(PreTypeConstraints.CommonConfirmationBag.InRealFamily, e.PreType, e.Origin, "type of real literal is used as {0}"); // TODO: make this error message have the same form as the one for integers above - } else if (e.Value is bool) { - e.PreType = CreatePreTypeProxy($"boolean literal '{e.Value.ToString().ToLower()}'"); + AddConfirmation(PreTypeConstraints.CommonConfirmationBag.InRealFamily, e.PreType, e.Origin, "real literal used as if it had type {0}"); + } else if (e.Value is bool boolValue) { + e.PreType = CreatePreTypeProxy($"boolean literal '{boolValue.ToString().ToLower()}'"); Constraints.AddDefaultAdvice(e.PreType, CommonAdvice.Target.Bool); AddConfirmation(PreTypeConstraints.CommonConfirmationBag.InBoolFamily, e.PreType, e.Origin, "boolean literal used as if it had type {0}"); } else if (e is CharLiteralExpr) { @@ -80,9 +82,10 @@ public void ResolveExpression(Expression expr, ResolutionContext resolutionConte Constraints.AddDefaultAdvice(e.PreType, CommonAdvice.Target.Char); AddConfirmation(PreTypeConstraints.CommonConfirmationBag.InCharFamily, e.PreType, e.Origin, "character literal used as if it had type {0}"); } else if (e is StringLiteralExpr) { - e.PreType = CreatePreTypeProxy($"string literal \"{e.Value}\""); - Constraints.AddDefaultAdvice(e.PreType, CommonAdvice.Target.String); - AddConfirmation(PreTypeConstraints.CommonConfirmationBag.InSeqFamily, e.PreType, e.Origin, "string literal used as if it had type {0}"); + var charPreType = CreatePreTypeProxy($"character in string literal"); + Constraints.AddDefaultAdvice(charPreType, CommonAdvice.Target.Char); + AddConfirmation(PreTypeConstraints.CommonConfirmationBag.InCharFamily, charPreType, e.Origin, "character literal used as if it had type {0}"); + ResolveCollectionProducingExpr(PreType.TypeNameSeq, $"string literal \"{e.Value}\"", e, charPreType, PreTypeConstraints.CommonConfirmationBag.InSeqFamily, true); } else { Contract.Assert(false); throw new cce.UnreachableException(); // unexpected literal type } @@ -476,7 +479,14 @@ resolutionContext.CodeContext is ConstantField || if (familyDeclName == PreType.TypeNameInt) { errorMessageFormat = "type conversion to an int-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got {1})"; } else if (familyDeclName == PreType.TypeNameReal) { - errorMessageFormat = "type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got {1})"; + var legacy = !resolver.Options.Get(CommonOptionBag.GeneralNewtypes); + if (legacy) { + errorMessageFormat = "type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got {1})"; + } else if (dtoPreType.Decl.Name == PreType.TypeNameReal) { + errorMessageFormat = "type conversion to real is allowed only from numeric-based types (got {1})"; + } else { + errorMessageFormat = "type conversion to a real-based type is allowed only from real (got {1})"; + } } else if (IsBitvectorName(familyDeclName)) { errorMessageFormat = "type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got {1})"; } else if (familyDeclName == PreType.TypeNameChar) { @@ -756,9 +766,9 @@ resolutionContext.CodeContext is ConstantField || } private void ResolveCollectionProducingExpr(string typeName, string exprKindSuffix, Expression expr, PreType elementPreType, - PreTypeConstraints.CommonConfirmationBag confirmationFamily) { - var exprKind = $"{typeName} {exprKindSuffix}"; - SetupCollectionProducingExpr(typeName, exprKind, expr, elementPreType); + PreTypeConstraints.CommonConfirmationBag confirmationFamily, bool isStringType = false) { + var exprKind = isStringType ? exprKindSuffix : $"{typeName} {exprKindSuffix}"; + SetupCollectionProducingExpr(typeName, isStringType, exprKind, expr, elementPreType); AddConfirmation(confirmationFamily, expr.PreType, expr.Origin, $"{exprKind} used as if it had type {{0}}"); } @@ -768,15 +778,16 @@ private void ResolveMapProducingExpr(bool finite, string exprKindSuffix, Express finite ? PreTypeConstraints.CommonConfirmationBag.InMapFamily : PreTypeConstraints.CommonConfirmationBag.InImapFamily; var exprKind = $"{typeName} {exprKindSuffix}"; - SetupCollectionProducingExpr(typeName, exprKind, expr, keyPreType, valuePreType); + SetupCollectionProducingExpr(typeName, false, exprKind, expr, keyPreType, valuePreType); AddConfirmation(confirmationFamily, expr.PreType, expr.Origin, $"{exprKind} used as if it had type {{0}}"); } - private void SetupCollectionProducingExpr(string typeName, string exprKind, Expression expr, PreType elementPreType, PreType valuePreType = null) { + private void SetupCollectionProducingExpr(string typeName, bool isStringType, string exprKind, Expression expr, PreType elementPreType, PreType valuePreType = null) { expr.PreType = CreatePreTypeProxy(exprKind); var arguments = valuePreType == null ? new List() { elementPreType } : new List() { elementPreType, valuePreType }; - var defaultType = new DPreType(BuiltInTypeDecl(typeName), arguments); + var defaultType = new DPreType(BuiltInTypeDecl(typeName), arguments, + isStringType ? new DPreType(BuiltInTypeDecl(PreType.TypeNameString), new List()) : null); Constraints.AddDefaultAdvice(expr.PreType, defaultType); Constraints.AddGuardedConstraint(() => { @@ -986,7 +997,6 @@ private PreType ResolveBinaryExpr(IOrigin tok, BinaryExpr.Opcode opcode, Express case BinaryExpr.Opcode.Div: resultPreType = CreatePreTypeProxy("result of / operation"); - Constraints.AddDefaultAdvice(resultPreType, CommonAdvice.Target.Int); AddConfirmation(PreTypeConstraints.CommonConfirmationBag.NumericOrBitvector, resultPreType, tok, "arguments to " + opString + " must be numeric or bitvector types (got {0})"); ConstrainOperandTypes(tok, opString, e0, e1, resultPreType); break; @@ -1107,9 +1117,8 @@ private void ConstrainOperandTypes(IOrigin tok, string opString, Expression e0, return (null, null); } - var receiverDecl = dReceiver.Decl; + var receiverDecl = dReceiver.DeclWithMembersBypassInternalSynonym(); if (receiverDecl is TopLevelDeclWithMembers receiverDeclWithMembers) { - // TODO: does this case need to do something like this? var cd = ctype?.AsTopLevelTypeWithMembersBypassInternalSynonym; var members = resolver.GetClassMembers(receiverDeclWithMembers); if (members == null || !members.TryGetValue(memberName, out var member)) { @@ -1125,6 +1134,9 @@ private void ConstrainOperandTypes(IOrigin tok, string opString, Expression e0, // TODO: We should return the original "member", not an overridden member. Alternatively, we can just return "member" so that the // caller can figure out the types, and then a later pass can figure out which particular "member" is intended. return (member, dReceiver); + } else if (reportErrorOnMissingMember) { + ReportError(tok, $"member '{memberName}' has not been imported in this scope and cannot be accessed here"); + return (null, null); } } if (reportErrorOnMissingMember) { @@ -1259,7 +1271,9 @@ public Expression ResolveNameSegment(NameSegment expr, bool isLastNameSegment, L } else if (isLastNameSegment && resolver.moduleInfo.Ctors.TryGetValue(name, out pair)) { // ----- 2. datatype constructor if (ResolveDatatypeConstructor(expr, args, resolutionContext, complain, pair, name, ref r, ref rWithArgs)) { - return null; + if (!complain) { + return null; + } } } else if (resolver.moduleInfo.TopLevels.TryGetValue(name, out var decl)) { @@ -1312,7 +1326,9 @@ public Expression ResolveNameSegment(NameSegment expr, bool isLastNameSegment, L } else if (!isLastNameSegment && resolver.moduleInfo.Ctors.TryGetValue(name, out pair)) { // ----- 5. datatype constructor if (ResolveDatatypeConstructor(expr, args, resolutionContext, complain, pair, name, ref r, ref rWithArgs)) { - return null; + if (!complain) { + return null; + } } } else { @@ -1422,7 +1438,7 @@ private bool ResolveDatatypeConstructor(NameSegment expr, List/*? if (args == null) { r = rr; } else { - r = rr; // this doesn't really matter, since we're returning an "rWithArgs" (but if would have been proper to have returned the ctor as a lambda) + r = rr; // this doesn't really matter, since we're returning an "rWithArgs" (but it would have been proper to have returned the ctor as a lambda) rWithArgs = rr; } return false; @@ -1491,7 +1507,7 @@ public Expression ResolveDotSuffix(ExprDotName expr, bool allowStaticReferenceTo ReportError(expr.Origin, "the name '{0}' denotes a datatype constructor in module {2}, but does not do so uniquely; add an explicit qualification (for example, '{1}.{0}')", name, pair.Item1.EnclosingDatatype.Name, ((ModuleDecl)ri.Decl).Name); } else { if (expr.OptTypeArguments != null) { - ReportError(expr.Origin, "datatype constructor does not take any type parameters ('{0}')", name); + ReportError(expr.Origin, $"datatype constructor does not take any type parameters ('{name}')"); } var rr = new DatatypeValue(expr.Origin, pair.Item1.EnclosingDatatype.Name, name, args ?? new List()); ResolveDatatypeValue(resolutionContext, rr, pair.Item1.EnclosingDatatype, null); @@ -1549,8 +1565,13 @@ public Expression ResolveDotSuffix(ExprDotName expr, bool allowStaticReferenceTo if (expr.OptTypeArguments != null) { ReportError(expr.Origin, $"datatype constructor does not take any type parameters ('{name}')"); } + var rr = new DatatypeValue(expr.Origin, ctor.EnclosingDatatype.Name, name, args ?? new List()); + if (ri.TypeArgs.Count != 0) { + rr.InferredTypeArgs = ri.TypeArgs; + } ResolveDatatypeValue(resolutionContext, rr, ctor.EnclosingDatatype, (DPreType)Type2PreType(ty)); + if (args == null) { r = rr; } else { @@ -1748,7 +1769,7 @@ public MethodCallInformation ResolveApplySuffix(ApplySuffix e, ResolutionContext // e.Lhs does denote a function value // In the general case, we'll resolve this as an ApplyExpr, but in the more common case of the Lhs // naming a function directly, we resolve this as a FunctionCallExpr. - var mse = e.Lhs is NameSegment || e.Lhs is ExprDotName ? e.Lhs.Resolved as MemberSelectExpr : null; + var mse = e.Lhs is NameSegment or ExprDotName ? e.Lhs.Resolved as MemberSelectExpr : null; var callee = mse?.Member as Function; if (atLabel != null && !(callee is TwoStateFunction)) { ReportError(e.AtTok, "an @-label can only be applied to a two-state function"); @@ -1759,7 +1780,9 @@ public MethodCallInformation ResolveApplySuffix(ApplySuffix e, ResolutionContext var rr = new FunctionCallExpr(e.Origin, mse.MemberNameNode, mse.Obj, e.Origin, e.CloseParen, e.Bindings, atLabel) { Function = callee, PreTypeApplication_AtEnclosingClass = mse.PreTypeApplicationAtEnclosingClass, - PreTypeApplication_JustFunction = mse.PreTypeApplicationJustMember + PreTypeApplication_JustFunction = mse.PreTypeApplicationJustMember, + TypeApplication_AtEnclosingClass = mse.TypeApplicationAtEnclosingClass, + TypeApplication_JustFunction = mse.TypeApplicationJustMember }; var typeMap = mse.PreTypeArgumentSubstitutionsAtMemberDeclaration(); var preTypeMap = BuildPreTypeArgumentSubstitute( @@ -1950,12 +1973,16 @@ public MethodCallInformation ResolveApplySuffix(ApplySuffix e, ResolutionContext private Expression DesugarDatatypeUpdate(IOrigin tok, Expression root, DPreType rootPreType, List candidateResultCtors, Dictionary> rhsBindings, ResolutionContext resolutionContext) { - Contract.Requires(1 <= candidateResultCtors.Count); + + if (candidateResultCtors.Count == 0) { + return root; + } // Create a unique name for d', the variable we introduce in the let expression var dName = resolver.FreshTempVarName("dt_update_tmp#", resolutionContext.CodeContext); - var dVar = new BoundVar(new AutoGeneratedOrigin(tok), dName, new InferredTypeProxy()); - dVar.PreType = rootPreType; + var dVar = new BoundVar(new AutoGeneratedOrigin(tok), dName, new InferredTypeProxy()) { + PreType = rootPreType + }; var d = new IdentifierExpr(new AutoGeneratedOrigin(tok), dVar); Expression body = null; candidateResultCtors.Reverse(); @@ -2184,15 +2211,15 @@ PreType ResolveSingleSelectionExpr(IOrigin tok, PreType collectionPreType, Expre void ResolveRangeSelectionExpr(IOrigin tok, PreType sourceCollectionPreType, Expression expr, Expression e0, Expression e1) { var resultElementPreType = CreatePreTypeProxy("index-range selection elements"); - SetupCollectionProducingExpr(PreType.TypeNameSeq, "index-range selection", expr, resultElementPreType); + SetupCollectionProducingExpr(PreType.TypeNameSeq, false, "index-range selection", expr, resultElementPreType); if (e0 != null) { ConstrainToIntFamilyOrBitvector(e0.PreType, e0.Origin, - "multi-element selection position expression must have an integer or bitvector type (got {0})"); + "multi-element selection expression must have an integer or bitvector type (got {0})"); } if (e1 != null) { ConstrainToIntFamilyOrBitvector(e1.PreType, e1.Origin, - "multi-element selection position expression must have an integer or bitvector type (got {0})"); + "multi-element selection expression must have an integer or bitvector type (got {0})"); } // In the expression s[e0..e1], correlate the type of s with the result type. diff --git a/Source/DafnyCore/Resolver/PreType/PreTypeResolve.cs b/Source/DafnyCore/Resolver/PreType/PreTypeResolve.cs index 58a3758cfb5..e779467387e 100644 --- a/Source/DafnyCore/Resolver/PreType/PreTypeResolve.cs +++ b/Source/DafnyCore/Resolver/PreType/PreTypeResolve.cs @@ -50,6 +50,10 @@ public void ReportError(IOrigin tok, string msg, params object[] args) { resolver.Reporter.Error(MessageSource.Resolver, tok, msg, args); } + public void ReportError(ResolutionErrors.ErrorId errorId, IOrigin tok, string msg, params object[] args) { + resolver.Reporter.Error(MessageSource.Resolver, errorId, tok, msg, args); + } + public void ReportWarning(IOrigin tok, string msg, params object[] args) { Contract.Requires(tok != null); Contract.Requires(msg != null); @@ -116,6 +120,8 @@ TopLevelDecl BuiltInTypeDecl(string name) { decl = new ValuetypeDecl(name, resolver.SystemModuleManager.SystemModule, variances, _ => false, null); } else if (name == PreType.TypeNameObjectQ) { decl = resolver.SystemModuleManager.ObjectDecl; + } else if (name == PreType.TypeNameString) { + decl = resolver.SystemModuleManager.StringDecl; } else { decl = new ValuetypeDecl(name, resolver.SystemModuleManager.SystemModule, _ => false, null); } @@ -520,17 +526,22 @@ void AddComparableConstraint(PreType a, PreType b, IOrigin tok, bool allowBaseTy Constraints.AddGuardedConstraint(() => ApproximateComparableConstraints(a, b, tok, allowBaseTypeCast, "(Duplicate error message) " + errorMessage(), false)); if (!allowBaseTypeCast) { - // The "comparable types" constraint may be useful as a bound if nothing else is known about a proxy. - if (a.Normalize() is PreTypeProxy aPreTypeProxy) { - Constraints.AddCompatibleBounds(aPreTypeProxy, b); - } - if (b.Normalize() is PreTypeProxy bPreTypeProxy) { - Constraints.AddCompatibleBounds(bPreTypeProxy, a); - } + AddComparableTypesDefault(a, b); } Constraints.AddConfirmation(tok, () => CheckComparableTypes(a, b, allowBaseTypeCast), errorMessage); } + private void AddComparableTypesDefault(PreType a, PreType b) { + // The "comparable types" constraint may be useful as a bound if nothing else is known about a proxy. + if (a.Normalize() is PreTypeProxy aPreTypeProxy) { + Constraints.AddCompatibleBounds(aPreTypeProxy, b); + } + + if (b.Normalize() is PreTypeProxy bPreTypeProxy) { + Constraints.AddCompatibleBounds(bPreTypeProxy, a); + } + } + /// /// This method returns whether or not A and B are comparable types (notated with the constraint A ~~ B). /// @@ -674,6 +685,7 @@ bool ApproximateComparableConstraints(PreType a, PreType b, IOrigin tok, bool al Constraints.AddEqualityConstraint(aa, bb, tok, msgFormat, null, reportErrors); } else { Constraints.AddGuardedConstraint(() => ApproximateComparableConstraints(aa, bb, tok, false, msgFormat, reportErrors)); + AddComparableTypesDefault(aa, bb); } } @@ -800,8 +812,8 @@ public void ResolveDeclarationSignature(Declaration d) { } if (preTypeInferenceModuleState.InFirstPhase.Contains(d)) { - var cycle = Util.Comma(" -> ", preTypeInferenceModuleState.InFirstPhase, d => d.ToString()); - ReportError(d, $"Cyclic dependency among declarations: {d} -> {cycle}"); + var cycle = Util.Comma(" -> ", preTypeInferenceModuleState.InFirstPhase, d => d.GetNameRelativeToModule()); + ReportError(d, $"Cyclic dependency among declarations: {d.GetNameRelativeToModule()} -> {cycle}"); } else { preTypeInferenceModuleState.InFirstPhase.Push(d); FillInPreTypesInSignature(d); @@ -1019,11 +1031,6 @@ public void ResolveAttributes(IAttributeBearingDeclaration attributeHost, Resolu Contract.Assert(usaa.Arg.Type != null); // Already resolved continue; } - if (attributeHost != null && attr is UserSuppliedAttributes usa) { -#if TODO - usa.Recognized = resolver.IsRecognizedAttribute(usa, attributeHost); // TODO: this could be done in a later resolution pass -#endif - } if (attr.Args != null) { foreach (var arg in attr.Args) { if (Attributes.Contains(attributeHost.Attributes, "opaque_reveal") && attr.Name is "revealedFunction" && arg is NameSegment nameSegment) { @@ -1391,9 +1398,16 @@ void ResolveFunction(Function f) { scope.PopMarker(); if (f.ByMethodBody != null) { + Contract.Assert(f.Body != null && !f.IsGhost); // assured by the parser and other callers of the Function constructor var method = f.ByMethodDecl; - Contract.Assert(method != null); // this should have been filled in by now - ResolveMethod(method); + if (method != null) { + ResolveMethod(method); + } else { + // method should have been filled in by now, + // unless there was a function by method and a method of the same name + // but then this error must have been reported. + Contract.Assert(resolver.Reporter.HasErrors); + } } resolver.Options.WarnShadowing = warnShadowingOption; // restore the original warnShadowing value diff --git a/Source/DafnyCore/Resolver/PreType/PreTypeResolver.Match.cs b/Source/DafnyCore/Resolver/PreType/PreTypeResolver.Match.cs index f91f0cf0416..27c7d5f6736 100644 --- a/Source/DafnyCore/Resolver/PreType/PreTypeResolver.Match.cs +++ b/Source/DafnyCore/Resolver/PreType/PreTypeResolver.Match.cs @@ -21,7 +21,7 @@ void ResolveNestedMatchStmt(NestedMatchStmt stmt, ResolutionContext resolutionCo ResolveAttributes(mc, resolutionContext, false); scope.PushMarker(); - ResolveExtendedPattern(stmt.Source.Origin, mc.Pat, stmt.Source.PreType, false, resolutionContext); + ResolveExtendedPattern(stmt.Source.Origin, mc.Pat, stmt.Source.PreType, false, false, resolutionContext); DominatingStatementLabels.PushMarker(); mc.Body.ForEach(ss => ResolveStatementWithLabels(ss, resolutionContext)); @@ -39,7 +39,7 @@ void ResolveNestedMatchExpr(NestedMatchExpr expr, ResolutionContext resolutionCo ResolveAttributes(mc, resolutionContext, false); scope.PushMarker(); - ResolveExtendedPattern(expr.Source.Origin, mc.Pat, expr.Source.PreType, false, resolutionContext); + ResolveExtendedPattern(expr.Source.Origin, mc.Pat, expr.Source.PreType, false, false, resolutionContext); ResolveExpression(mc.Body, resolutionContext); AddSubtypeConstraint(expr.PreType, mc.Body.PreType, mc.Body.Origin, @@ -69,10 +69,16 @@ bool InsistOnKnowingPreType(IOrigin tok, PreType preType) { /// /// Resolve "pattern" and push onto "scope" all its bound variables. /// - public void ResolveExtendedPattern(IOrigin sourceExprToken, ExtendedPattern pattern, PreType preType, bool inDisjunctivePattern, ResolutionContext resolutionContext) { + public void ResolveExtendedPattern(IOrigin sourceExprToken, ExtendedPattern pattern, PreType preType, + bool inPattern, bool inDisjunctivePattern, ResolutionContext resolutionContext) { + if (pattern is DisjunctivePattern dp) { + if (inPattern) { + ReportError(dp.Origin, "Disjunctive patterns are not allowed inside other patterns"); + } + foreach (var alt in dp.Alternatives) { - ResolveExtendedPattern(sourceExprToken, alt, preType, true, resolutionContext); + ResolveExtendedPattern(sourceExprToken, alt, preType, true, true, resolutionContext); } return; } @@ -86,7 +92,7 @@ public void ResolveExtendedPattern(IOrigin sourceExprToken, ExtendedPattern patt } var idPattern = (IdPattern)pattern; - if (idPattern.Type is not TypeProxy) { + if (idPattern.Type is not TypeProxy || idPattern.IsWildcardPattern) { Contract.Assert(idPattern.Arguments == null); // the parser ensures this condition (the ID cannot be followed by both "(...)" and ": ...") resolver.ResolveType(idPattern.Origin, idPattern.Type, resolutionContext, ResolveTypeOptionEnum.InferTypeProxies, null); // When a type is supplied, the ID is understood to be a bound variable. @@ -149,14 +155,13 @@ public void ResolveExtendedPattern(IOrigin sourceExprToken, ExtendedPattern patt var subst = PreType.PreTypeSubstMap(dtd.TypeArgs, dpreType.Arguments); for (var i = 0; i < idPattern.Arguments.Count; i++) { var argumentPreType = ctor.Formals[i].PreType.Substitute(subst); - ResolveExtendedPattern(sourceExprToken, idPattern.Arguments[i], argumentPreType, inDisjunctivePattern, resolutionContext); + ResolveExtendedPattern(sourceExprToken, idPattern.Arguments[i], argumentPreType, true, inDisjunctivePattern, resolutionContext); } } /// - /// Tries to resolve "idPattern" as a symbolic constant with a LiteralExpr RHS. - /// - /// Return "true" iff "idPattern" is a symbolic constant with a RHS (regardless of what that RHS is). + /// Tries to resolve "idPattern" as a symbolic constant with a LiteralExpr RHS, and + /// returns "true" upon success. /// /// If there is such a RHS and that RHS is a LiteralExpr, then /// * record the RHS literal as "idPattern.ResolvedLit", and @@ -172,10 +177,10 @@ private bool TryResolvingAsConst(IdPattern idPattern, PreType preType, bool repo // the ID refers to a const whose RHS is a literal idPattern.ResolvedLit = lit; AddSubtypeConstraint(preType, lit.PreType, idPattern.Origin, "literal pattern (of type {1}) cannot be used with source type {0}"); + return true; } else if (reportErrors) { ReportError(idPattern.Origin, $"{idPattern.Id} is not initialized as a constant literal"); } - return true; } return false; } diff --git a/Source/DafnyCore/Resolver/PreType/PreTypeSubtypeConstraint.cs b/Source/DafnyCore/Resolver/PreType/PreTypeSubtypeConstraint.cs index 371367b2016..fb410ffa7cb 100644 --- a/Source/DafnyCore/Resolver/PreType/PreTypeSubtypeConstraint.cs +++ b/Source/DafnyCore/Resolver/PreType/PreTypeSubtypeConstraint.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using System.Diagnostics.Contracts; +using JetBrains.Annotations; namespace Microsoft.Dafny { class SubtypeConstraint : OptionalErrorPreTypeConstraint { @@ -78,7 +79,7 @@ public bool Apply(PreTypeConstraints constraints) { // else do nothing for now if (ptSuper.Decl is not TraitDecl) { var arguments = CreateProxiesForTypesAccordingToVariance(tok, ptSuper.Decl.TypeArgs, ptSuper.Arguments, false, ReportErrors, constraints); - var pt = new DPreType(ptSuper.Decl, arguments); + var pt = new DPreType(ptSuper.Decl, arguments, KeepIfTypeSynonym(ptSuper.PrintablePreType)); constraints.AddEqualityConstraint(pt, sub, tok, ErrorFormatString, null, ReportErrors); return true; } @@ -94,7 +95,7 @@ public bool Apply(PreTypeConstraints constraints) { // there are parent traits } else { var arguments = CreateProxiesForTypesAccordingToVariance(tok, ptSub.Decl.TypeArgs, ptSub.Arguments, true, ReportErrors, constraints); - var pt = new DPreType(ptSub.Decl, arguments); + var pt = new DPreType(ptSub.Decl, arguments, KeepIfTypeSynonym(ptSub.PrintablePreType)); constraints.AddEqualityConstraint(super, pt, tok, ErrorFormatString, null, ReportErrors); return true; } @@ -104,6 +105,15 @@ public bool Apply(PreTypeConstraints constraints) { return false; } + [CanBeNull] + DPreType KeepIfTypeSynonym([CanBeNull] DPreType dPreType) { + if (dPreType is { Decl: TypeSynonymDecl and not SubsetTypeDecl }) { + return dPreType; + } + + return null; + } + /// /// For every non-variant parameters[i], constrain superArguments[i] == subArguments[i]. /// For every co-variant parameters[i], constrain superArguments[i] :> subArguments[i]. diff --git a/Source/DafnyCore/Resolver/PreType/PreTypeToType.cs b/Source/DafnyCore/Resolver/PreType/PreTypeToType.cs index 0f54f2e37c5..1f03deeeddc 100644 --- a/Source/DafnyCore/Resolver/PreType/PreTypeToType.cs +++ b/Source/DafnyCore/Resolver/PreType/PreTypeToType.cs @@ -124,6 +124,14 @@ protected override void PostVisitOneExpression(Expression expr, IASTVisitorConte VisitPattern(lhs, context); } } else if (expr is DatatypeValue datatypeValue) { + // If the datatype has no type parameters, then .InferredTypeArgs.Count == .InferredPreTypeArgs.Count == 0. + // If it has type parameters, say n of them, then: + // with Ctor(args), .InferredTypeArgs.Count == 0 and .InferredPreTypeArgs.Count == n + // with Dt.Ctor(args), .InferredTypeArgs.Count == .InferredPreTypeArgs.Count == n + // with Dt.Ctor(args), .InferredTypeArgs.Count == .InferredPreTypeArgs.Count == n where the .InferredTypeArgs are + // all InferredTypeProxy's. + // Note that "TArgs" may contain types whose type arguments are InferredTypeProxy's; this happens if a type argument + // in "TArgs" is given without its arguments Contract.Assert(datatypeValue.InferredTypeArgs.Count == 0 || datatypeValue.InferredTypeArgs.Count == datatypeValue.InferredPreTypeArgs.Count); if (datatypeValue.InferredTypeArgs.Any(typeArg => typeArg is InferredTypeProxy)) { Contract.Assert(datatypeValue.InferredTypeArgs.All(typeArg => typeArg is InferredTypeProxy)); @@ -132,15 +140,15 @@ protected override void PostVisitOneExpression(Expression expr, IASTVisitorConte Contract.Assert(datatypeValue.InferredPreTypeArgs.Count == datatypeDecl.TypeArgs.Count); for (var i = 0; i < datatypeDecl.TypeArgs.Count; i++) { - var formal = datatypeDecl.TypeArgs[i]; var actualPreType = datatypeValue.InferredPreTypeArgs[i]; if (i < datatypeValue.InferredTypeArgs.Count) { var givenTypeOrProxy = datatypeValue.InferredTypeArgs[i]; PreType2TypeUtil.Combine(givenTypeOrProxy, actualPreType, givenTypeOrProxy is TypeProxy); } else { - datatypeValue.InferredTypeArgs.Add(PreType2TypeUtil.PreType2RefinableType(actualPreType, formal.Variance)); + datatypeValue.InferredTypeArgs.Add(PreType2TypeUtil.PreType2RefinableType(actualPreType)); } } + } else if (expr is ConversionExpr conversionExpr) { PreType2TypeUtil.Combine(conversionExpr.ToType, conversionExpr.PreType, false); expr.Type = conversionExpr.ToType; @@ -190,7 +198,7 @@ protected override void PostVisitOneExpression(Expression expr, IASTVisitorConte } // Case: refinement-wrapper pre-type type - expr.UnnormalizedType = PreType2TypeUtil.PreType2RefinableType(expr.PreType, TypeParameter.TPVariance.Co); + expr.UnnormalizedType = PreType2TypeUtil.PreType2RefinableType(expr.PreType); } private void VisitPattern(CasePattern casePattern, IASTVisitorContext context) where VT : class, IVariable { diff --git a/Source/DafnyCore/Resolver/PreType/TypeRefinementVisitor.cs b/Source/DafnyCore/Resolver/PreType/TypeRefinementVisitor.cs index b4e0efd7cb1..8ccbd5383c0 100644 --- a/Source/DafnyCore/Resolver/PreType/TypeRefinementVisitor.cs +++ b/Source/DafnyCore/Resolver/PreType/TypeRefinementVisitor.cs @@ -163,6 +163,21 @@ protected override void PostVisitOneExpression(Expression expr, IASTVisitorConte "map display")); } + } else if (expr is SeqUpdateExpr seqUpdateExpr) { + if (expr.Type is MultiSetType multiSetType) { + flows.Add(new FlowBetweenExpressions(expr, seqUpdateExpr.Seq, "multiset update (source)")); + flows.Add(new FlowFromComputedTypeIgnoreHeadTypes(expr, + () => new MultiSetType(TypeRefinementWrapper.NormalizeSansBottom(seqUpdateExpr.Index)), + "multiset update (element)")); + } else if (expr.Type is MapType mapType) { + flows.Add(new FlowBetweenExpressions(expr, seqUpdateExpr.Seq, "map update (source)")); + flows.Add(new FlowFromComputedTypeIgnoreHeadTypes(expr, () => new MapType(mapType.Finite, + TypeRefinementWrapper.NormalizeSansBottom(seqUpdateExpr.Index), TypeRefinementWrapper.NormalizeSansBottom(seqUpdateExpr.Value)), + "map update (element)")); + } else { + // nothing to do for sequences + } + } else if (expr is SetComprehension setComprehension) { flows.Add(new FlowFromComputedTypeIgnoreHeadTypes(expr, () => new SetType(setComprehension.Finite, TypeRefinementWrapper.NormalizeSansBottom(setComprehension.Term)), diff --git a/Source/DafnyCore/Resolver/PreType/UnderspecificationDetector.cs b/Source/DafnyCore/Resolver/PreType/UnderspecificationDetector.cs index 6bd41c987fa..b74e2b6ab22 100644 --- a/Source/DafnyCore/Resolver/PreType/UnderspecificationDetector.cs +++ b/Source/DafnyCore/Resolver/PreType/UnderspecificationDetector.cs @@ -84,11 +84,11 @@ public void Check(List declarations) { for (int i = 1; i < dtor.CorrespondingFormals.Count; i++) { var other = dtor.CorrespondingFormals[i]; if (!Type.Equal_Improved(rolemodel.Type, other.Type)) { - ReportError(other.Origin, + ReportError(ResolutionErrors.ErrorId.r_shared_destructors_have_different_types, other.Origin, "shared destructors must have the same type, but '{0}' has type '{1}' in constructor '{2}' and type '{3}' in constructor '{4}'", rolemodel.Name, rolemodel.Type, dtor.EnclosingCtors[0].Name, other.Type, dtor.EnclosingCtors[i].Name); } else if (rolemodel.IsGhost != other.IsGhost) { - ReportError(other.Origin, + ReportError(ResolutionErrors.ErrorId.r_shared_destructors_have_different_types, other.Origin, "shared destructors must agree on whether or not they are ghost, but '{0}' is {1} in constructor '{2}' and {3} in constructor '{4}'", rolemodel.Name, rolemodel.IsGhost ? "ghost" : "non-ghost", dtor.EnclosingCtors[0].Name, @@ -289,13 +289,15 @@ protected override void VisitOneExpr(Expression expr) { var absN = n < 0 ? -n : n; // For bitvectors, check that the magnitude fits the width if (PreTypeResolver.IsBitvectorName(familyDeclName, out var width) && ConstantFolder.MaxBv(width) < absN) { - cus.ReportError(e.Origin, "literal ({0}) is too large for the bitvector type {1}", absN, e.PreType); + cus.ReportError(ResolutionErrors.ErrorId.r_literal_too_large_for_bitvector, e.Origin, + "literal ({0}) is too large for the bitvector type {1}", absN, e.PreType); } // For bitvectors and ORDINALs, check for a unary minus that, earlier, was mistaken for a negative literal // This can happen only in `match` patterns (see comment by LitPattern.OptimisticallyDesugaredLit). if (n < 0 || e.Origin.val == "-0") { Contract.Assert(e.Origin.val == "-0"); // this and the "if" above tests that "n < 0" happens only when the token is "-0" - cus.ReportError(e.Origin, "unary minus (-{0}, type {1}) not allowed in case pattern", absN, e.PreType); + cus.ReportError(ResolutionErrors.ErrorId.r_no_unary_minus_in_case_patterns, e.Origin, + "unary minus (-{0}, type {1}) not allowed in case pattern", absN, e.PreType); } } @@ -364,6 +366,7 @@ protected override void VisitOneExpr(Expression expr) { if (expr is UnaryOpExpr uop) { var resolvedOp = (uop.Op, PreTypeResolver.AncestorName(uop.E.PreType)) switch { (UnaryOpExpr.Opcode.Not, PreType.TypeNameBool) => UnaryOpExpr.ResolvedOpcode.BoolNot, + (UnaryOpExpr.Opcode.Not, _) => UnaryOpExpr.ResolvedOpcode.BVNot, (UnaryOpExpr.Opcode.Cardinality, PreType.TypeNameSet) => UnaryOpExpr.ResolvedOpcode.SetCard, (UnaryOpExpr.Opcode.Cardinality, PreType.TypeNameSeq) => UnaryOpExpr.ResolvedOpcode.SeqLength, (UnaryOpExpr.Opcode.Cardinality, PreType.TypeNameMultiset) => UnaryOpExpr.ResolvedOpcode.MultiSetCard, @@ -371,8 +374,10 @@ protected override void VisitOneExpr(Expression expr) { (UnaryOpExpr.Opcode.Fresh, _) => UnaryOpExpr.ResolvedOpcode.Fresh, (UnaryOpExpr.Opcode.Allocated, _) => UnaryOpExpr.ResolvedOpcode.Allocated, (UnaryOpExpr.Opcode.Lit, _) => UnaryOpExpr.ResolvedOpcode.Lit, + (UnaryOpExpr.Opcode.Assigned, _) => UnaryOpExpr.ResolvedOpcode.Assigned, _ => UnaryOpExpr.ResolvedOpcode.YetUndetermined // Unreachable }; + Contract.Assert(resolvedOp != UnaryOpExpr.ResolvedOpcode.YetUndetermined); if (uop.Op == UnaryOpExpr.Opcode.Not && PreTypeResolver.IsBitvectorName(familyDeclName)) { resolvedOp = UnaryOpExpr.ResolvedOpcode.BVNot; } diff --git a/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionTranslator.cs b/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionTranslator.cs index 9a88be88a45..c5087d3cada 100644 --- a/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionTranslator.cs +++ b/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionTranslator.cs @@ -528,7 +528,8 @@ public Boogie.Expr TrExpr(Expression expr) { args.Add(Old.HeapExpr); } if (!fn.IsStatic) { - args.Add(/* translator.BoxIfUnboxed */(TrExpr(e.Obj)/*, e.Type */)); + Boogie.Expr obj = BoogieGenerator.BoxifyForTraitParent(e.Origin, TrExpr(e.Obj), e.Member, e.Obj.Type); + args.Add(obj); } return FunctionCall(GetToken(e), BoogieGenerator.FunctionHandle(fn), Predef.HandleType, args); }); @@ -2125,7 +2126,8 @@ public Boogie.Expr GoodRef(IOrigin tok, Boogie.Expr e, Type type) { public Expression MakeAllowance(FunctionCallExpr e, CanCallOptions cco = null) { Expression allowance = Expression.CreateBoolLiteral(e.Origin, true); if (!e.Function.IsStatic) { - allowance = Expression.CreateAnd(allowance, Expression.CreateEq(e.Receiver, new ThisExpr(e.Function), e.Receiver.Type)); + var formalThis = new ThisExpr(cco == null ? e.Function : cco.EnclosingFunction); + allowance = Expression.CreateAnd(allowance, Expression.CreateEq(e.Receiver, formalThis, e.Receiver.Type)); } var formals = cco == null ? e.Function.Ins : cco.EnclosingFunction.Ins; for (int i = 0; i < e.Args.Count; i++) { diff --git a/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionWellformed.cs b/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionWellformed.cs index e41e5935038..161599625d0 100644 --- a/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionWellformed.cs +++ b/Source/DafnyCore/Verifier/BoogieGenerator.ExpressionWellformed.cs @@ -289,6 +289,14 @@ public void CheckWellformedWithResult(Expression expr, WFOptions wfOptions, } case LiteralExpr: CheckResultToBeInType(expr.Origin, expr, expr.Type, locals, builder, etran); + if (expr is StringLiteralExpr stringLiteralExpr) { + var ancestorSeqType = (SeqType)expr.Type.NormalizeToAncestorType(); + var elementType = ancestorSeqType.Arg; + foreach (var ch in Util.UnescapedCharacters(options, (string)stringLiteralExpr.Value, stringLiteralExpr.IsVerbatim)) { + var rawElement = FunctionCall(GetToken(stringLiteralExpr), BuiltinFunction.CharFromInt, null, Boogie.Expr.Literal(ch)); + CheckSubrange(expr.Origin, rawElement, Type.Char, elementType, expr, builder); + } + } break; case ThisExpr: case WildcardExpr: diff --git a/Source/DafnyCore/Verifier/BoogieGenerator.Functions.cs b/Source/DafnyCore/Verifier/BoogieGenerator.Functions.cs index d84708e3b8e..fdf2c8e4b8f 100644 --- a/Source/DafnyCore/Verifier/BoogieGenerator.Functions.cs +++ b/Source/DafnyCore/Verifier/BoogieGenerator.Functions.cs @@ -667,8 +667,7 @@ public string FunctionHandle(Function f) { } else { name = f.FullSanitizedName + "#Handle"; functionHandles[f] = name; - var args = new List(); - var vars = MkTyParamBinders(GetTypeParams(f), out args); + var vars = MkTyParamBinders(GetTypeParams(f), out var args); var argsRequires = new List(args); // Requires don't have reveal parameters var formals = MkTyParamFormals(GetTypeParams(f), false, true); var tyargs = new List(); diff --git a/Source/DafnyCore/Verifier/BoogieGenerator.Methods.cs b/Source/DafnyCore/Verifier/BoogieGenerator.Methods.cs index bbe45a1e715..0e5eb8a121f 100644 --- a/Source/DafnyCore/Verifier/BoogieGenerator.Methods.cs +++ b/Source/DafnyCore/Verifier/BoogieGenerator.Methods.cs @@ -1095,10 +1095,8 @@ private void AddFunctionOverrideCheckImpl(Function f) { private void AddFunctionOverrideEnsChk(Function f, BoogieStmtListBuilder builder, ExpressionTranslator etran, - Dictionary substMap, - Dictionary typeMap, - List implInParams, - Bpl.Variable/*?*/ resultVariable) { + Dictionary substMap, Dictionary typeMap, + List implInParams, Bpl.Variable/*?*/ resultVariable) { Contract.Requires(f.Ins.Count <= implInParams.Count); var cco = new CanCallOptions(true, f); @@ -1141,27 +1139,25 @@ private void AddFunctionOverrideEnsChk(Function f, BoogieStmtListBuilder builder } // conjunction of class post-conditions - var allOverrideEns = f.Ens.Count == 0 ? null : f.Ens + var allOverrideEns = f.Ens .Select(e => e.E) - .Aggregate((e0, e1) => new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.And, e0, e1)); + .Aggregate((Expression)Expression.CreateBoolLiteral(f.Origin, true), (e0, e1) => Expression.CreateAnd(e0, e1)); //generating trait post-conditions with class variables cco = new CanCallOptions(true, f, true); - FunctionCallSubstituter sub = null; + FunctionCallSubstituter sub = new FunctionCallSubstituter(substMap, typeMap, + (TraitDecl)f.OverriddenFunction.EnclosingClass, (TopLevelDeclWithMembers)f.EnclosingClass); foreach (var en in ConjunctsOf(f.OverriddenFunction.Ens)) { - sub ??= new FunctionCallSubstituter(substMap, typeMap, (TraitDecl)f.OverriddenFunction.EnclosingClass, (TopLevelDeclWithMembers)f.EnclosingClass); var subEn = sub.Substitute(en.E); foreach (var s in TrSplitExpr(new BodyTranslationContext(false), subEn, etran, false, out _).Where(s => s.IsChecked)) { builder.Add(TrAssumeCmd(f.Origin, etran.CanCallAssumption(subEn, cco))); - var constraint = allOverrideEns == null - ? null - : new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.Imp, allOverrideEns, subEn); + var constraint = Expression.CreateImplies(allOverrideEns, subEn); builder.Add(Assert(f.Origin, s.E, new FunctionContractOverride(true, constraint), builder.Context)); } } } private void AddOverrideCheckTypeArgumentInstantiations(MemberDecl member, BoogieStmtListBuilder builder, Variables localVariables) { - Contract.Requires(member is Function || member is Method); + Contract.Requires(member is Function or Method); Contract.Requires(member.EnclosingClass is TopLevelDeclWithMembers); Contract.Requires(builder != null); Contract.Requires(localVariables != null); @@ -1187,13 +1183,12 @@ private void AddOverrideCheckTypeArgumentInstantiations(MemberDecl member, Boogi private void AddFunctionOverrideSubsetChk(Function func, BoogieStmtListBuilder builder, ExpressionTranslator etran, Variables localVariables, - Dictionary substMap, - Dictionary typeMap) { + Dictionary substMap, Dictionary typeMap) { //getting framePrime List traitFrameExps = new List(); - FunctionCallSubstituter sub = null; + FunctionCallSubstituter sub = new FunctionCallSubstituter(substMap, typeMap, + (TraitDecl)func.OverriddenFunction.EnclosingClass, (TopLevelDeclWithMembers)func.EnclosingClass); foreach (var e in func.OverriddenFunction.Reads.Expressions) { - sub ??= new FunctionCallSubstituter(substMap, typeMap, (TraitDecl)func.OverriddenFunction.EnclosingClass, (TopLevelDeclWithMembers)func.EnclosingClass); var newE = sub.Substitute(e.E); FrameExpression fe = new FrameExpression(e.Origin, newE, e.FieldName); traitFrameExps.Add(fe); @@ -1208,10 +1203,10 @@ private void AddFunctionOverrideSubsetChk(Function func, BoogieStmtListBuilder b Contract.Assert(traitFrame.Type != null); // follows from the postcondition of ReadsFrame var frame = localVariables.GetOrAdd(new Bpl.LocalVariable(tok, new Bpl.TypedIdent(tok, null ?? traitFrame.Name, traitFrame.Type))); // $_ReadsFrame := (lambda $o: ref, $f: Field :: $o != null && $Heap[$o,alloc] ==> ($o,$f) in Modifies/Reads-Clause); - Bpl.BoundVariable oVar = new Bpl.BoundVariable(tok, new Bpl.TypedIdent(tok, "$o", Predef.RefType)); - Bpl.IdentifierExpr o = new Bpl.IdentifierExpr(tok, oVar); - Bpl.BoundVariable fVar = new Bpl.BoundVariable(tok, new Bpl.TypedIdent(tok, "$f", Predef.FieldName(tok))); - Bpl.IdentifierExpr f = new Bpl.IdentifierExpr(tok, fVar); + var oVar = new Bpl.BoundVariable(tok, new Bpl.TypedIdent(tok, "$o", Predef.RefType)); + var o = new Bpl.IdentifierExpr(tok, oVar); + var fVar = new Bpl.BoundVariable(tok, new Bpl.TypedIdent(tok, "$f", Predef.FieldName(tok))); + var f = new Bpl.IdentifierExpr(tok, fVar); Bpl.Expr ante = BplAnd(Bpl.Expr.Neq(o, Predef.Null), etran.IsAlloced(tok, o)); Bpl.Expr consequent = InRWClause(tok, o, f, traitFrameExps, etran, null, null); Bpl.Expr lambda = new Bpl.LambdaExpr(tok, new List(), new List { oVar, fVar }, null, @@ -1230,33 +1225,30 @@ private void AddFunctionOverrideSubsetChk(Function func, BoogieStmtListBuilder b } private void AddFunctionOverrideReqsChk(Function f, BoogieStmtListBuilder builder, ExpressionTranslator etran, - Dictionary substMap, - Dictionary typeMap) { + Dictionary substMap, Dictionary typeMap) { Contract.Requires(f != null); Contract.Requires(builder != null); Contract.Requires(etran != null); Contract.Requires(substMap != null); //generating trait pre-conditions with class variables var cco = new CanCallOptions(true, f, true); - FunctionCallSubstituter sub = null; + FunctionCallSubstituter sub = new FunctionCallSubstituter(substMap, typeMap, + (TraitDecl)f.OverriddenFunction.EnclosingClass, (TopLevelDeclWithMembers)f.EnclosingClass); var subReqs = new List(); foreach (var req in ConjunctsOf(f.OverriddenFunction.Req)) { - sub ??= new FunctionCallSubstituter(substMap, typeMap, (TraitDecl)f.OverriddenFunction.EnclosingClass, (TopLevelDeclWithMembers)f.EnclosingClass); var subReq = sub.Substitute(req.E); builder.Add(TrAssumeCmd(f.Origin, etran.CanCallAssumption(subReq, cco))); builder.Add(TrAssumeCmdWithDependencies(etran, f.Origin, subReq, "overridden function requires clause")); subReqs.Add(subReq); } - var allTraitReqs = subReqs.Count == 0 ? null : subReqs - .Aggregate((e0, e1) => new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.And, e0, e1)); + + var allTraitReqs = subReqs.Aggregate((Expression)Expression.CreateBoolLiteral(f.Origin, true), (e0, e1) => Expression.CreateAnd(e0, e1)); //generating class pre-conditions cco = new CanCallOptions(true, f); foreach (var req in ConjunctsOf(f.Req)) { foreach (var s in TrSplitExpr(new BodyTranslationContext(false), req.E, etran, false, out _).Where(s => s.IsChecked)) { builder.Add(TrAssumeCmd(f.Origin, etran.CanCallAssumption(req.E, cco))); - var constraint = allTraitReqs == null - ? null - : new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.Imp, allTraitReqs, req.E); + var constraint = Expression.CreateImplies(allTraitReqs, req.E); builder.Add(Assert(f.Origin, s.E, new FunctionContractOverride(false, constraint), builder.Context)); } } @@ -1508,19 +1500,17 @@ private void AddMethodOverrideEnsChk(Method m, BoogieStmtListBuilder builder, Ex builder.Add(TrAssumeCmdWithDependencies(etran, m.Origin, en.E, "overridden ensures clause")); } // conjunction of class post-conditions - var allOverrideEns = m.Ens.Count == 0 ? null : m.Ens + var allOverrideEns = m.Ens .Select(e => e.E) - .Aggregate((e0, e1) => new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.And, e0, e1)); + .Aggregate((Expression)Expression.CreateBoolLiteral(m.Origin, true), (e0, e1) => Expression.CreateAnd(e0, e1)); //generating trait post-conditions with class variables - FunctionCallSubstituter sub = null; + FunctionCallSubstituter sub = new FunctionCallSubstituter(substMap, typeMap, + (TraitDecl)m.OverriddenMethod.EnclosingClass, (TopLevelDeclWithMembers)m.EnclosingClass); foreach (var en in ConjunctsOf(m.OverriddenMethod.Ens)) { - sub ??= new FunctionCallSubstituter(substMap, typeMap, (TraitDecl)m.OverriddenMethod.EnclosingClass, (TopLevelDeclWithMembers)m.EnclosingClass); var subEn = sub.Substitute(en.E); foreach (var s in TrSplitExpr(new BodyTranslationContext(false), subEn, etran, false, out _).Where(s => s.IsChecked)) { builder.Add(TrAssumeCmd(m.OverriddenMethod.Origin, etran.CanCallAssumption(subEn))); - var constraint = allOverrideEns == null - ? null - : new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.Imp, allOverrideEns, subEn); + var constraint = Expression.CreateImplies(allOverrideEns, subEn); builder.Add(Assert(m.Origin, s.E, new EnsuresStronger(constraint), builder.Context)); } } @@ -1534,32 +1524,29 @@ private void AddMethodOverrideReqsChk(Method m, BoogieStmtListBuilder builder, E Contract.Requires(etran != null); Contract.Requires(substMap != null); //generating trait pre-conditions with class variables - FunctionCallSubstituter sub = null; + FunctionCallSubstituter sub = new FunctionCallSubstituter(substMap, typeMap, + (TraitDecl)m.OverriddenMethod.EnclosingClass, (TopLevelDeclWithMembers)m.EnclosingClass); var subReqs = new List(); foreach (var req in ConjunctsOf(m.OverriddenMethod.Req)) { - sub ??= new FunctionCallSubstituter(substMap, typeMap, (TraitDecl)m.OverriddenMethod.EnclosingClass, (TopLevelDeclWithMembers)m.EnclosingClass); var subReq = sub.Substitute(req.E); builder.Add(TrAssumeCmd(m.OverriddenMethod.Origin, etran.CanCallAssumption(subReq))); builder.Add(TrAssumeCmdWithDependencies(etran, m.Origin, subReq, "overridden requires clause")); subReqs.Add(subReq); } - var allTraitReqs = subReqs.Count == 0 ? null : subReqs - .Aggregate((e0, e1) => new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.And, e0, e1)); - //generating class pre-conditions + var allTraitReqs = subReqs.Aggregate((Expression)Expression.CreateBoolLiteral(m.Origin, true), (e0, e1) => Expression.CreateAnd(e0, e1)); + + // generating class pre-conditions foreach (var req in ConjunctsOf(m.Req)) { foreach (var s in TrSplitExpr(new BodyTranslationContext(false), req.E, etran, false, out _).Where(s => s.IsChecked)) { builder.Add(TrAssumeCmd(m.Origin, etran.CanCallAssumption(req.E))); - var constraint = allTraitReqs == null - ? null - : new BinaryExpr(Token.NoToken, BinaryExpr.Opcode.Imp, allTraitReqs, req.E); + var constraint = Expression.CreateImplies(allTraitReqs, req.E); builder.Add(Assert(m.Origin, s.E, new RequiresWeaker(constraint), builder.Context)); } } } private void AddOverrideTerminationChk(ICallable original, ICallable overryd, BoogieStmtListBuilder builder, ExpressionTranslator etran, - Dictionary substMap, - Dictionary typeMap) { + Dictionary substMap, Dictionary typeMap) { Contract.Requires(original != null); Contract.Requires(overryd != null); Contract.Requires(builder != null); @@ -1638,8 +1625,7 @@ private void AddOverrideTerminationChk(ICallable original, ICallable overryd, Bo } private void AddMethodOverrideFrameSubsetChk(Method m, bool isModifies, BoogieStmtListBuilder builder, ExpressionTranslator etran, Variables localVariables, - Dictionary substMap, - Dictionary typeMap) { + Dictionary substMap, Dictionary typeMap) { List classFrameExps; List originalTraitFrameExps; @@ -1658,20 +1644,21 @@ private void AddMethodOverrideFrameSubsetChk(Method m, bool isModifies, BoogieSt // Trivially true return; } + + var sub = new FunctionCallSubstituter(substMap, typeMap, (TraitDecl)m.OverriddenMethod.EnclosingClass, (TopLevelDeclWithMembers)m.EnclosingClass); foreach (var e in originalTraitFrameExps) { - var newE = Substitute(e.E, null, substMap, typeMap); + var newE = sub.Substitute(e.E); var fe = new FrameExpression(e.Origin, newE, e.FieldName); traitFrameExps.Add(fe); } } - - var kv = etran.TrAttributes(m.Attributes, null); var tok = m.Origin; var canCalls = traitFrameExps.Concat(classFrameExps) .Select(e => etran.CanCallAssumption(e.E)) .Aggregate((Bpl.Expr)Bpl.Expr.True, BplAnd); builder.Add(TrAssumeCmd(tok, canCalls)); + var oVar = new Boogie.BoundVariable(tok, new Boogie.TypedIdent(tok, "$o", Predef.RefType)); var o = new Boogie.IdentifierExpr(tok, oVar); var fVar = new Boogie.BoundVariable(tok, new Boogie.TypedIdent(tok, "$f", Predef.FieldName(tok))); @@ -1684,6 +1671,7 @@ private void AddMethodOverrideFrameSubsetChk(Method m, bool isModifies, BoogieSt var q = new Boogie.ForallExpr(tok, new List(), new List { oVar, fVar }, BplImp(BplAnd(ante, oInCallee), consequent2)); var description = new TraitFrame(m.WhatKind, isModifies, classFrameExps, traitFrameExps); + var kv = etran.TrAttributes(m.Attributes, null); builder.Add(Assert(m.Origin, q, description, builder.Context, kv)); } diff --git a/Source/DafnyCore/Verifier/BoogieGenerator.Types.cs b/Source/DafnyCore/Verifier/BoogieGenerator.Types.cs index 6b83567e3d1..8626b3050bd 100644 --- a/Source/DafnyCore/Verifier/BoogieGenerator.Types.cs +++ b/Source/DafnyCore/Verifier/BoogieGenerator.Types.cs @@ -1197,15 +1197,16 @@ Bpl.Expr ConvertExpression(IOrigin tok, Bpl.Expr r, Type fromType, Type toType) return UnboxUnlessInherentlyBoxed(r, toType); } else if (fromType.IsSubtypeOf(toType, false, false)) { return AdaptBoxing(r.tok, r, fromType, toType); - } else if (fromType is CollectionType && toType is CollectionType) { - // the Boogie representation of collection types is the same for all element types - return r; - } else if (fromType.Equals(toType) || fromType.AsNewtype != null || toType.AsNewtype != null) { - return r; } else { - Contract.Assert(false, $"No translation implemented from {fromType} to {toType}"); + // In all other legal cases, the representations of "fromType" and "toType" are the same. + // The following assertion shows which cases we expect. + Contract.Assert( + Type.SameHead(fromType, toType) || + fromType.AsNewtype != null || + toType.AsNewtype != null + ); + return r; } - return r; } private Bpl.Expr IntToBV(IOrigin tok, Bpl.Expr r, Type toType) { @@ -1255,11 +1256,7 @@ void PutSourceIntoLocal() { Contract.Assert(options.Get(CommonOptionBag.GeneralTraits) != CommonOptionBag.GeneralTraitsOptions.Legacy || fromType.IsRefType == toType.IsRefType || (fromType.IsTypeParameter && toType.IsTraitType)); - if (toType.IsRefType) { - PutSourceIntoLocal(); - CheckSubrange(tok, o, fromType, toType, expr, builder, errorMsgPrefix); - return; - } else if (fromType.IsTraitType) { + if (toType.IsRefType || fromType.IsTraitType || toType.IsArrowType) { PutSourceIntoLocal(); CheckSubrange(tok, o, fromType, toType, expr, builder, errorMsgPrefix); return; diff --git a/Source/DafnyLanguageServer.Test/Diagnostics/DiagnosticsTest.cs b/Source/DafnyLanguageServer.Test/Diagnostics/DiagnosticsTest.cs index 957ac6270d8..aac26e8abfe 100644 --- a/Source/DafnyLanguageServer.Test/Diagnostics/DiagnosticsTest.cs +++ b/Source/DafnyLanguageServer.Test/Diagnostics/DiagnosticsTest.cs @@ -435,9 +435,11 @@ decreases y var documentItem = CreateTestDocument(source, "OpeningDocumentWithSemanticErrorReportsDiagnosticsWithSemanticErrors.dfy"); await client.OpenDocumentAndWaitAsync(documentItem, CancellationToken); var diagnostics = await diagnosticsReceiver.AwaitNextDiagnosticsAsync(CancellationToken); - Assert.Single(diagnostics); - Assert.Equal("Resolver", diagnostics[0].Source); - Assert.Equal(DiagnosticSeverity.Error, diagnostics[0].Severity); + Assert.Equal(2, diagnostics.Length); + Assert.Equal("Resolver", diagnostics[1].Source); + Assert.Equal(DiagnosticSeverity.Error, diagnostics[1].Severity); + Assert.Equal("Resolver", diagnostics[1].Source); + Assert.Equal(DiagnosticSeverity.Error, diagnostics[1].Severity); await AssertNoDiagnosticsAreComing(CancellationToken); } diff --git a/Source/DafnyLanguageServer.Test/Synchronization/OpenDocumentTest.cs b/Source/DafnyLanguageServer.Test/Synchronization/OpenDocumentTest.cs index 93e0393e050..c45185d08f5 100644 --- a/Source/DafnyLanguageServer.Test/Synchronization/OpenDocumentTest.cs +++ b/Source/DafnyLanguageServer.Test/Synchronization/OpenDocumentTest.cs @@ -53,8 +53,9 @@ function GetConstant(): int { var document = await Projects.GetResolvedDocumentAsyncNormalizeUri(documentItem.Uri); Assert.NotNull(document); var diagnostics = await GetLastDiagnostics(documentItem); - Assert.Single(diagnostics); + Assert.Equal(2, diagnostics.Length); Assert.Equal(MessageSource.Resolver.ToString(), diagnostics[0].Source); + Assert.Equal(MessageSource.Resolver.ToString(), diagnostics[1].Source); } [Fact] diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy index 9e63f833a38..ae8e861bc5f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy @@ -7,10 +7,66 @@ method M() ensures false { var r := new Pack<() ~> bool>[1]; - r[0] := Pack(() => false); + var tf := Pack(() reads r, r[0].c.reads => if r[0].c.requires() then !r[0].c() else false ); - // error: r[0] calls itself without decreasing - r[0] := tf; -} \ No newline at end of file + // the following would be trouble, if allowed, because then r[0] calls itself without decreasing + r[0] := tf; // error: not allowed to assign a Pack<() ~> bool> to a heap memory location +} + +method R0(r: array bool>>) + requires r.Length != 0 + modifies r +{ + // The syntactic use of a "reads" clause in the following line causes the lambda expression to be typed + // as "() ~> bool". The assignment thus incurs a proof obligation that the function value doesn't actually + // read the heap (despite its static type). If the rest of the program let us get past the resolver, then + // the verifier can dismiss this proof obligation. + // (The "Pack(...)" in the RHS may be typed as either "Pack(~>)" or "Pack(->)", but in either case, the + // proof obligation just mentioned still applies, either directly to the lambda expression or to the entire + // RHS.) + var p: Pack<() -> bool> := Pack(() reads {} => false); + // The types of the LHS ("Pack(~>)") and RHS ("Pack(->)") are allowed in the assignment, but they cause + // a proof obligation that the RHS really is a "Pack(~>)". This verifier is able to prove that. + // Therefore, there is neither a "~> assigned to memory" nor a "RHS not assignable to LHS" error in the + // following line. + r[0] := p; + // Note, what was just said here about proof obligations and the verifier is confirmed in Knot18.dfy. +} + +method R1(r: array bool>>) + requires r.Length != 0 + modifies r +{ + // The lambda expression in the following line is typed as "() -> bool", but the enclosing "Pack(...)" + // is typed as "Pack<() ~> bool>" to match the LHS. However, an -> arrow is assignable to a ~>, so + // the use of a "() -> bool" as the argument to the "Pack" constructor works just fine. + var p: Pack<() ~> bool> := Pack(() => false); + r[0] := p; // error: not allowed to assign a Pack<() ~> bool> to a heap memory location +} + +method R2(r: array bool>>) + requires r.Length != 0 + modifies r +{ + // In the following line, the new resolver infers + // - the type of "() => false" to be "() -> bool", that is, an arrow without read effects + // - the type of the RHS to be "Pack<() -> bool>" + // Since the LHS has type "Pack<() ~> bool>", the is a proof obligation that the RHS really is a "Pack<() ~> bool>". + // As can be observed in R0, that proof obligation goes through. + // In the legacy resolver, the RHS is typed liked the LHS, so the type of the RHS is "Pack<() ~> bool>". This means + // that the check for assigning a ~> into a memory location fails. + r[0] := Pack(() => false); // (legacy resolver) error: not allowed to assign a Pack<() ~> bool> to a heap memory location +} + +method R3(r: array bool>>) + requires r.Length != 0 + modifies r +{ + // In the following line, the new resolver infers + // - the type of "() reads {} => false" to be "() ~> bool", that is, an arrow with potential read effects + // - the type of the RHS to be "Pack(() ~> bool)" + // Due to the latter, the error we get is that a "~>" arrow is being assigned to a memory location. + r[0] := Pack(() reads {} => false); // error: not allowed to assign a Pack<() ~> bool> to a heap memory location +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.expect index f9708d94c12..e26d1ae364c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.expect @@ -1,3 +1,5 @@ -Knot10.dfy(10,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed Knot10.dfy(15,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed -2 resolution/type errors detected in Knot10.dfy +Knot10.dfy(46,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +Knot10.dfy(60,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +Knot10.dfy(71,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +4 resolution/type errors detected in Knot10.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.refresh.expect new file mode 100644 index 00000000000..4c1174d2192 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot10.dfy.refresh.expect @@ -0,0 +1,4 @@ +Knot10.dfy(15,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +Knot10.dfy(46,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +Knot10.dfy(71,7): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +3 resolution/type errors detected in Knot10.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy index 4034981623a..5c764ee4b40 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy @@ -8,10 +8,11 @@ method M() { var r := new array bool>>[1]; r[0] := new Pack<() ~> bool>[1]; - r[0][0] := Pack(() => false); + var p: Pack<() -> bool> := Pack(() => false); // see comments in Knot10.dfy + r[0][0] := p; var tf := Pack(() reads r, r[0], r[0][0].c.reads => if r[0][0].c.requires() then !r[0][0].c() else false ); // error: r[0][0].c calls itself without decreasing r[0][0] := tf; -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy.expect index 0efe5ead486..604a147850c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot12.dfy.expect @@ -1,3 +1,2 @@ -Knot12.dfy(11,10): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed -Knot12.dfy(16,10): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed -2 resolution/type errors detected in Knot12.dfy +Knot12.dfy(17,10): Error: To prevent the creation of non-terminating functions, storing functions with read effects into memory is disallowed +1 resolution/type errors detected in Knot12.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot18.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot18.dfy new file mode 100644 index 00000000000..e527f214224 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot18.dfy @@ -0,0 +1,24 @@ +// RUN: %verify "%s" > "%t" +// RUN: %diff "%s.expect" "%t" + +datatype Pack = Pack(ghost c: T) + +method R0(r: array bool>>) + requires r.Length != 0 + modifies r +{ + // For a description, see method R0 in Knot10.dfy. + var p: Pack<() -> bool> := Pack(() reads {} => false); + r[0] := p; +} + +method R2(r: array bool>>) + requires r.Length != 0 + modifies r +{ + // In the following line, the new resolver infers + // - the type of "() => false" to be "() -> bool", that is, an arrow without read effects + // - the type of the RHS to be "Pack<() -> bool>" + // Since the LHS has type "Pack<() ~> bool>", the is a proof obligation that the RHS really is a "Pack<() ~> bool>". + r[0] := Pack(() => false); +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot18.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot18.dfy.expect new file mode 100644 index 00000000000..ba00363fc08 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/Landin/Knot18.dfy.expect @@ -0,0 +1,2 @@ + +Dafny program verifier finished with 4 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/auditor/TestAuditor.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/auditor/TestAuditor.dfy.expect index 504bd0676df..fab6c18dfcf 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/auditor/TestAuditor.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/auditor/TestAuditor.dfy.expect @@ -2,11 +2,11 @@ TestAuditor.dfy(24,25): Warning: This ensures clause is part of a bodyless metho TestAuditor.dfy(38,2): Warning: assume statement has no {:axiom} annotation TestAuditor.dfy(136,2): Warning: assume statement has no {:axiom} annotation TestAuditor.dfy(150,11): Warning: Assertion with {:only} temporarily transforms other assertions into assumptions -TestAuditor.dfy(154,9): Warning: Members with {:only} temporarily disable the verification of other members in the entire file TestAuditor.dfy(95,4): Warning: this forall statement has no body TestAuditor.dfy(102,4): Warning: this loop has no body (loop frame: i) TestAuditor.dfy(139,2): Warning: this forall statement has no body TestAuditor.dfy(143,2): Warning: this loop has no body (loop frame: i) +TestAuditor.dfy(154,9): Warning: Members with {:only} temporarily disable the verification of other members in the entire file TestAuditor.dfy(93,10): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. TestAuditor.dfy(95,4): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. TestAuditor.dfy(139,2): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/cli/libraryOption/libraryOption.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/cli/libraryOption/libraryOption.dfy.expect index 3b35a7bf7d2..7599f528d5d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/cli/libraryOption/libraryOption.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/cli/libraryOption/libraryOption.dfy.expect @@ -1,3 +1,3 @@ CLI: Warning: The file 'brokenProducer.dfy' was passed to --library. Verification for that file might have used options incompatible with the current ones, or might have been skipped entirely. Use a .doo file to enable Dafny to check that compatible options were used -brokenProducer.dfy(1,9): Error: Function body type mismatch (expected int, got bool) +brokenProducer.dfy(2,2): Error: boolean literal used as if it had type int 1 resolution/type errors detected in libraryOption.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AsIs-Compile-Expanded.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AsIs-Compile-Expanded.dfy index b8215cff1e6..67a7982fb53 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AsIs-Compile-Expanded.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AsIs-Compile-Expanded.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=true +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=true --general-newtypes=false method Main() { Is.Test(); diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AutoInit.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AutoInit.dfy index 8c6c956a0ce..7561a37236d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AutoInit.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/AutoInit.dfy @@ -99,7 +99,7 @@ method Arrows() { method DoNothing(F: int ~> pos) { } module NilRegression { - trait Trait { } + trait Trait extends object { } class Class extends Trait { } method Test() { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Collections.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Collections.dfy index 79b6f16b4a9..417787e58ae 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Collections.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Collections.dfy @@ -15,7 +15,7 @@ method Main() { // ------------------------------------------------------------------------------------------- -trait Trait { } +trait Trait extends object { } class Class extends Trait { } type IntSet = set diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Comprehensions.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Comprehensions.dfy index 0cdad5075c1..2cd4e6a1859 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Comprehensions.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Comprehensions.dfy @@ -253,7 +253,7 @@ method Sequences() { print nats, "\n"; } -trait NothingInParticular { } +trait NothingInParticular extends object { } class ClassA { } class ClassB extends NothingInParticular { } @@ -341,7 +341,7 @@ method SetComprehension3() { print |d|, " ", |e|, "\n"; // 3 3 } -trait ICell { var data: int } +trait ICell extends object { var data: int } class CellA extends ICell { } class CellB extends ICell { } @@ -423,7 +423,7 @@ method GoNil() { print "there are ", |dd|, " elements in the union\n"; // 3 } -trait SomethingElse { } +trait SomethingElse extends object { } method Containment(s: set, t: set, u: set) { // Test that the type parameter emitted by the compiler accommodates that of both @@ -447,7 +447,7 @@ method Containment(s: set, t: set, u: set) { } module TestImplicitTypeTests { - trait A {} + trait A extends object {} trait B extends A {} class C extends B {} class A' extends A {} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/ComprehensionsNewSyntax.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/ComprehensionsNewSyntax.dfy index d3206c736ce..d2d0c26bb5b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/ComprehensionsNewSyntax.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/ComprehensionsNewSyntax.dfy @@ -63,7 +63,7 @@ method XM() returns (x: int) { print "after: ", f(), " ", "before: ", f(), "\n"; } -trait NothingInParticular { } +trait NothingInParticular extends object { } class ClassA { } class ClassB extends NothingInParticular { } @@ -151,7 +151,7 @@ method SetComprehension3() { print |d|, " ", |e|, "\n"; // 3 3 } -trait ICell { var data: int } +trait ICell extends object { var data: int } class CellA extends ICell { } class CellB extends ICell { } @@ -224,7 +224,7 @@ method EnumerationsMaybeNull() { } module TestImplicitTypeTests { - trait A {} + trait A extends object {} trait B extends A {} class C extends B {} class A' extends A {} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy index a0565555b09..664d5d90917 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment --spill-translation +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false --relax-definite-assignment --spill-translation method Main() { Sequences(); @@ -235,7 +235,7 @@ method PrintMap(prefix: string, M: map) { print sep; // pick smallest Number in s ghost var min := ThereIsASmallest(s); - var x :| x in s && forall y :: y in s ==> x.value <= y.value; + var x: Number :| x in s && forall y: Number :: y in s ==> x.value <= y.value; x.Print(); print " := "; m[x].Print(); diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/DowncastClone.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/DowncastClone.dfy index cb1f095b3f4..ccb455bf88e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/DowncastClone.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/DowncastClone.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment --general-newtypes=true --type-system-refresh=true datatype Co<+T> = Co(T) | C datatype ReCo<+T> = ReCo(T) @@ -22,7 +22,7 @@ method DowncastCo() { var i := new Y(); var a: Co := Co(i); var b: Co; - b := a; + b := a as Co; print a, " and ", b, "\n"; } @@ -30,12 +30,12 @@ method DowncastReCo() { var i := new Y(); var a: ReCo := ReCo(i); var b: ReCo; - b := a; + b := a as ReCo; print a, " and ", b, "\n"; - var s := new ClassWithFields(a); + var s := new ClassWithFields(a as ReCo); print s.y, " "; - s.y := a; + s.y := a as ReCo; print s.y, "\n"; } @@ -44,7 +44,7 @@ method DowncastContra() { var i: Contra := Contra(_ => false); var a: Contra := i; var b: Contra; - b := a; + b := a as Contra; print a.f(y), " and ", b.f(y), "\n"; } @@ -53,7 +53,7 @@ method DowncastReContra() { var i: ReContra := ReContra(_ => false); var a: ReContra := i; var b: ReContra; - b := a; + b := a as ReContra; print a.f(y), " and ", b.f(y), "\n"; } @@ -61,7 +61,7 @@ method DowncastFunc() { var i := new Y(); var a: bool -> X := (_ => i); var b: bool -> Y; - b := a; + b := a as bool -> Y; print a(false), " and ", b(false), "\n"; } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/GeneralNewtypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/GeneralNewtypes.dfy index 9bd1467a018..5b438590492 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/GeneralNewtypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/GeneralNewtypes.dfy @@ -186,7 +186,7 @@ module Char { var c, u, r := Comparisons(); print c, " ", u, " ", r, "\n"; // 'e' 'E' true MyString([u, u, u]); - MyString("hello"); + MyString("HELLO"); Mix(); GoodOl'Char('B'); } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Libraries/consumer.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Libraries/consumer.dfy index 8603e432373..3fd39caa46a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Libraries/consumer.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Libraries/consumer.dfy @@ -1,4 +1,4 @@ -// RUN: %translate cs --allow-warnings --library "%S/Inputs/directLibrary.dfy" --library "%S/Inputs/secondLibrary.dfy" "%s" > "%t" +// RUN: %translate cs --use-basename-for-filename --allow-warnings --library "%S/Inputs/directLibrary.dfy" --library "%S/Inputs/secondLibrary.dfy" "%s" > "%t" // RUN: %diff "%s.expect" "%t" // RUN: %OutputCheck "%s" --file-to-check="%S/consumer.cs" // CHECK: GloballyUniqueProducer @@ -13,4 +13,4 @@ module ConsumingModule { import B = GloballyUniqueProducer.ExportingModule const myConstant := A.exportedVariable + B.exportedVariable -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/MoreAutoInit.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/MoreAutoInit.dfy index b708af6f7e2..fa5c18a4ce5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/MoreAutoInit.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/MoreAutoInit.dfy @@ -247,7 +247,7 @@ module Consts { static const StaticD1: Ad := StaticD0 } - trait Trait { + trait Trait extends object { const InstanceT0: At const InstanceT1: At := InstanceT0 const InstanceT2: At diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Numbers.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Numbers.dfy index e446b5d5f16..3b477d1e63b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Numbers.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Numbers.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: https://github.com/dafny-lang/dafny/issues/4174 -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --type-system-refresh=false --general-newtypes=false --relax-definite-assignment method Main() { Literals(); diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Poly.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Poly.dfy index a8ce980b329..1083b1f5a4d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Poly.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/Poly.dfy @@ -1,7 +1,7 @@ // NONUNIFORM: https://github.com/dafny-lang/dafny/issues/4174 // RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment --spill-translation -trait Shape { +trait Shape extends object { function Center(): (real, real) reads this method PrintCenter() { print "Center: ", this.Center(), "\n"; @@ -76,7 +76,7 @@ method PrintSet(shapes: set) { var ordered := []; while |s| != 0 { ghost var _ := ThereIsASmallest(s); - var shape :| shape in s && forall shape' :: shape' in s ==> shape.Center().0 <= shape'.Center().0; + var shape: Shape :| shape in s && forall shape': Shape :: shape' in s ==> shape.Center().0 <= shape'.Center().0; ordered := ordered + [shape]; s := s - {shape}; } @@ -100,7 +100,7 @@ method PrintMultiSet(shapes: multiset) { var ordered := []; while |s| != 0 { ghost var _ := ThereIsASmallestInMultiset(s); - var shape :| shape in s && forall shape' :: shape' in s ==> shape.Center().0 <= shape'.Center().0; + var shape: Shape :| shape in s && forall shape': Shape :: shape' in s ==> shape.Center().0 <= shape'.Center().0; ordered := ordered + [shape]; s := s - multiset{shape}; } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeDescriptors.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeDescriptors.dfy index 67b52357b76..9c07fc24e34 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeDescriptors.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeDescriptors.dfy @@ -60,7 +60,7 @@ method Main() { // datatypes Method("AtomicShells", Atom(true)); Method("AtomicShells>", Atom(Atom(3))); - Method("AtomicShells>", Atom(Atom(3 as pos))); + Method("AtomicShells>", Atom(AtomicShells.Atom(3 as pos))); var u: Class := new Class; Method("Record, Class>", Record, Class>.SimpleRecord(5, u)); @@ -131,7 +131,7 @@ function Up(x: int): Stream { More(x, Up(x + 1)) } -trait Trait { } +trait Trait extends object { } class Class extends Trait> { } function IntBoolFunction(x: int): bool diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeParams.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeParams.dfy index 51a19772940..83905e4c6b7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeParams.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/TypeParams.dfy @@ -95,7 +95,7 @@ class Cl { } } -trait HTrait { +trait HTrait extends object { const h0: Stream var h1: Stream diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/UnicodeStrings.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/UnicodeStrings.dfy index 3a0980ea727..cb1c8d5a1fa 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/UnicodeStrings.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/UnicodeStrings.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --unicode-char +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --type-system-refresh=false --general-newtypes=false --unicode-char method AssertAndExpect(p: bool) requires p diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/arrays.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/arrays.dfy index 5f11c241c18..0320fd41c2d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/arrays.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/arrays.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: Rust-specific tests -// RUN: %baredafny run --target=rs "%s" > "%t" +// RUN: %baredafny run --target=rs --general-traits=legacy "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Origin.Imported { @@ -29,4 +29,4 @@ method Main() { reads intWrappers requires 0 <= i < 3 => intWrappers[i]); var index := 1 as Index; expect intWrappers[index] == intWrappers2[1, 1]; -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/avoid_soundness_mut.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/avoid_soundness_mut.dfy index 2335ca7bd41..2ff164e931a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/avoid_soundness_mut.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/avoid_soundness_mut.dfy @@ -41,4 +41,4 @@ method Main() { assert false; print "Soundness issue\n"; } -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/cargoreleasefailure.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/cargoreleasefailure.dfy index e247b923cfc..4f26d0ead59 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/cargoreleasefailure.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/cargoreleasefailure.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: Rust-specific tests -// RUN: %baredafny build --target=rs "%s" +// RUN: %baredafny build --target=rs --general-traits=legacy "%s" // If there is no '#[inline(never)]' in front of ::dafny_runtime::increment_strong_count // then the release will think it's safe to remove the strong count increment, resulting ins a segfault // RUN: "%S/cargoreleasefailure-rust/cargo" run --release @@ -45,4 +45,4 @@ module MainModule { method Main() { WorkModule.DoWork(); } -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/externalclasses.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/externalclasses.dfy index c6d50772615..1bdec9c3f3a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/externalclasses.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/externalclasses.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: Rust-specific tests -// RUN: %baredafny run --target=rs --input "%S/externalclasses.rs" "%s" > "%t" +// RUN: %baredafny run --target=rs --general-traits=legacy --input "%S/externalclasses.rs" "%s" > "%t" // RUN: %diff "%s.expect" "%t" module {:extern "External.Class.Container"} ExternalClassContainer { @@ -100,4 +100,4 @@ method Main() { expect n.Get() == "x"; expect n.GetOpt() == "Some(x)"; print message; -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy index 06db986522e..9d43932cebc 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: Rust-specific tests -// RUN: %baredafny run --target=rs --unicode-char=false "%s" > "%t" +// RUN: %baredafny run --target=rs --unicode-char=false --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" function Map(m: map): map { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/tests.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/tests.dfy index e431975b417..f4ce51b1da8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/tests.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/tests.dfy @@ -1,6 +1,6 @@ // NONUNIFORM: Test of the Dafny-to-Rust tests // RUN: %baredafny test --target=rs "%s" > "%t" -// RUN: %diff "%s.expect" "%t +// RUN: %diff "%s.expect" "%t" // RUN: %baredafny build --compile-suffix --target=rs "%s" > "%t" // RUN: "%S/tests-rust/cargo" run -- Hello > "%t" // RUN: %diff "%s.main.expect" "%t" @@ -19,4 +19,4 @@ module WrappedTests { print args[1]; } } -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/traits.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/traits.dfy index bf9fa40f586..0a96553cd24 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/traits.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/traits.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: Rust-specific tests -// RUN: %baredafny run --target=rs "%s" > "%t" +// RUN: %baredafny run --target=rs --general-traits=legacy "%s" > "%t" // RUN: %diff "%s.expect" "%t" module InterfaceHolder { @@ -195,8 +195,8 @@ module All { var aOwned := a; var o: TraitNoArgs := a as TraitNoArgs; expect o is ClassNoArgs; - ConsumeClassNoArgs(o); - ConsumeClassNoArgs(o); + ConsumeClassNoArgs(o as ClassNoArgs); + ConsumeClassNoArgs(o as ClassNoArgs); var oo: object := o as object; expect oo is ClassNoArgs; ConsumeClassNoArgs(oo as ClassNoArgs); @@ -250,4 +250,4 @@ module All { print "Main passed all the tests\n"; } -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/translate-additional/more_dafny.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/translate-additional/more_dafny.dfy index c55fc26cb3f..aec89b7e71b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/translate-additional/more_dafny.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/translate-additional/more_dafny.dfy @@ -21,4 +21,4 @@ function reverse(input: bv16): (result: bv16) { lemma reverseDoubleIsIdentity(input: bv16) ensures reverse(reverse(input)) == input { -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/type-test.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/type-test.dfy index 75ee7a0c39c..4e851f85348 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/type-test.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/type-test.dfy @@ -1,7 +1,7 @@ // NONUNIFORM: Tests that type tests work in the Rust backend -// RUN: %baredafny run --target=rs "%s" > "%t" +// RUN: %baredafny run --target=rs --general-traits=legacy "%s" > "%t" // RUN: %diff "%s.expect" "%t" -// RUN: %baredafny run --target=rs --raw-pointers "%s" > "%t" +// RUN: %baredafny run --target=rs --general-traits=legacy --raw-pointers "%s" > "%t" // RUN: %diff "%s.expect" "%t" trait T { } @@ -12,4 +12,4 @@ method Main() { var v: T := new A(); expect !(v is B), "v shouldn't be B"; expect v is A, "v should be A"; -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/separate-compilation/usesTimesTwo.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/separate-compilation/usesTimesTwo.dfy index eec3e311b9b..805f699bc46 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/separate-compilation/usesTimesTwo.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/separate-compilation/usesTimesTwo.dfy @@ -66,7 +66,7 @@ module ConsumerModule { } method PickANat() returns (n: nat) { - n := PickSomething(); + n := PickSomething(); } method PickSomething() returns (t: T) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/01-InnerOuter.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/01-InnerOuter.dfy index 698525e2e64..ee12fc9dabc 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/01-InnerOuter.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/01-InnerOuter.dfy @@ -4,7 +4,7 @@ // This program shows how to model an outer type whose invariant refers to the invariant of an inner type. // A universe of objects playing under LCI rules -trait S { +trait S extends object { // The set of objects in the universe ghost var obs: set @@ -39,7 +39,7 @@ trait S { } // A generic object trait -trait O { +trait O extends object { // Universe of which O is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/02-DoubleRead.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/02-DoubleRead.dfy index 53c62c827f2..f2b146dd729 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/02-DoubleRead.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/02-DoubleRead.dfy @@ -16,7 +16,7 @@ ghost function upCast(o: object): object {o} // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe ghost var content: set @@ -63,7 +63,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/03-SimpleCounter.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/03-SimpleCounter.dfy index 3b3e3805d9b..fc5441fb42f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/03-SimpleCounter.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/03-SimpleCounter.dfy @@ -17,7 +17,7 @@ ghost function upCast(o: object): object {o} // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe ghost var content: set @@ -64,7 +64,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/04-LeastGreatest.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/04-LeastGreatest.dfy index a2b2454d6a6..1933cba6a1f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/04-LeastGreatest.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/04-LeastGreatest.dfy @@ -64,11 +64,11 @@ lemma BuildBAux(k: ORDINAL, x: Object) ensures B#[k](x) { // Mutually recursive, using two different traits -trait TraitA { +trait TraitA extends object { var b: TraitB } -trait TraitB { +trait TraitB extends object { var a: TraitA } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/05-RecInvariantCut.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/05-RecInvariantCut.dfy index a3c33bd7e37..537c3a81cd2 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/05-RecInvariantCut.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/05-RecInvariantCut.dfy @@ -8,7 +8,7 @@ ghost function upCast(o: object): object {o} // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe ghost var content: set @@ -51,7 +51,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/06-ThreadOwnership.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/06-ThreadOwnership.dfy index 6137755bf13..fe428631191 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/06-ThreadOwnership.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/06-ThreadOwnership.dfy @@ -4,7 +4,7 @@ // This program shows how to encode ownership and the property that objects owned by a thread that doesn't execute don't change. // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe ghost var content: set @@ -70,7 +70,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/07-CounterThreadOwnership.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/07-CounterThreadOwnership.dfy index 8b2a3f6662f..994edac0be1 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/07-CounterThreadOwnership.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/07-CounterThreadOwnership.dfy @@ -22,7 +22,7 @@ // } // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe var content: set @@ -233,7 +233,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/08-CounterNoTermination.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/08-CounterNoTermination.dfy index e15772ae83d..75bdb370688 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/08-CounterNoTermination.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/08-CounterNoTermination.dfy @@ -22,7 +22,7 @@ // } // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe ghost var content: set @@ -80,7 +80,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/09-CounterNoStateMachine.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/09-CounterNoStateMachine.dfy index f8d015415ab..fb8fc629161 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/09-CounterNoStateMachine.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/09-CounterNoStateMachine.dfy @@ -22,7 +22,7 @@ // } // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe var content: set @@ -233,7 +233,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/10-SequenceInvariant.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/10-SequenceInvariant.dfy index 098d30d3d4b..8def5a28d24 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/10-SequenceInvariant.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/10-SequenceInvariant.dfy @@ -5,7 +5,7 @@ // The encoding used using sequential code and claims. // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe var content: set @@ -186,7 +186,7 @@ trait Universe { } // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy index 6a534428f33..ab44a2c8130 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy @@ -5,7 +5,7 @@ // To speed up the verification: /vcsLoad:0.5 /proverOpt:O:smt.qi.eager_threshold=30 // A universe of objects playing under LCI rules -trait Universe { +trait Universe extends object { // The set of objects in the universe ghost var content: set @@ -291,7 +291,7 @@ method InterferenceWithFraming(ghost universe: Universe, ghost preempting: Threa datatype ObjectClassKind = Thread | OwnedObject | Lifetime // A generic object trait -trait Object { +trait Object extends object { // Universe of which the Object is a member. // This should really be a constant, but I don't know how to do that while factoring out join below, // because traits can't have constructors. @@ -761,7 +761,7 @@ class Mutex extends OwnedObject { ghost predicate volatileOwns() { true } ghost function objectUserFields(): set reads this { - var r: set := guards + { data }; r + guards + { data } } twostate predicate unchangedNonvolatileUserFields() reads this { true } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy.expect index 7271da1866c..50110466a23 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/concurrency/12-MutexLifetime-short.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 385 verified, 0 errors +Dafny program verifier finished with 386 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ArrayElementInitResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ArrayElementInitResolution.dfy index a63923e7ebe..c73bbc53e9c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ArrayElementInitResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ArrayElementInitResolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module AM { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy index 640a59a43f0..af950d490af 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy @@ -1,9 +1,9 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" -// RUN: %diff "%s.expect" "%t" +// RUN: %testDafnyForEachResolver --expect-exit-code=2 "%s" + module Types { - trait A { } - trait B { } + trait A extends object { } + trait B extends object { } trait C extends A> { } trait D extends B, C { } class K { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy.refresh.expect new file mode 100644 index 00000000000..8264b5f78f3 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Resolve.dfy.refresh.expect @@ -0,0 +1,73 @@ +AsIs-Resolve.dfy(23,15): Error: RHS (of type M) not assignable to LHS (of type int) +AsIs-Resolve.dfy(24,18): Error: RHS (of type M) not assignable to LHS (of type Opaque) +AsIs-Resolve.dfy(25,19): Error: RHS (of type M) not assignable to LHS (of type ValSyn) +AsIs-Resolve.dfy(26,6): Error: RHS (of type M?) not assignable to LHS (of type int) +AsIs-Resolve.dfy(27,6): Error: RHS (of type M?) not assignable to LHS (of type Opaque) +AsIs-Resolve.dfy(28,7): Error: RHS (of type M?) not assignable to LHS (of type ValSyn) +AsIs-Resolve.dfy(32,15): Error: type conversion to an int-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got M<_T0>) +AsIs-Resolve.dfy(33,15): Error: type cast to type 'Opaque' must be from an expression of a compatible type (got 'M<_T0>') +AsIs-Resolve.dfy(34,16): Error: type conversion to an ORDINAL type is allowed only from numeric and bitvector types, char, and ORDINAL (got M<_T0>) +AsIs-Resolve.dfy(35,12): Error: type conversion to an int-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got M?<_T0>) +AsIs-Resolve.dfy(36,12): Error: type cast to type 'Opaque' must be from an expression of a compatible type (got 'M?<_T0>') +AsIs-Resolve.dfy(37,13): Error: type conversion to an ORDINAL type is allowed only from numeric and bitvector types, char, and ORDINAL (got M?<_T0>) +AsIs-Resolve.dfy(49,13): Error: RHS (of type M) not assignable to LHS (of type K) +AsIs-Resolve.dfy(50,13): Error: RHS (of type M) not assignable to LHS (of type L) +AsIs-Resolve.dfy(52,19): Error: RHS (of type M) not assignable to LHS (of type RefSyn) +AsIs-Resolve.dfy(58,6): Error: RHS (of type M?) not assignable to LHS (of type K) +AsIs-Resolve.dfy(59,6): Error: RHS (of type M?) not assignable to LHS (of type L) +AsIs-Resolve.dfy(61,7): Error: RHS (of type M?) not assignable to LHS (of type RefSyn) +AsIs-Resolve.dfy(67,15): Error: RHS (of type M) not assignable to LHS (of type K?) +AsIs-Resolve.dfy(68,15): Error: RHS (of type M) not assignable to LHS (of type L?) +AsIs-Resolve.dfy(70,21): Error: RHS (of type M) not assignable to LHS (of type RefSyn?) +AsIs-Resolve.dfy(76,7): Error: RHS (of type M?) not assignable to LHS (of type K?) +AsIs-Resolve.dfy(77,7): Error: RHS (of type M?) not assignable to LHS (of type L?) +AsIs-Resolve.dfy(79,8): Error: RHS (of type M?) not assignable to LHS (of type RefSyn?) +AsIs-Resolve.dfy(91,15): Error: type cast to reference type 'K' must be from an expression of a compatible type (got 'M') +AsIs-Resolve.dfy(92,15): Error: type cast to reference type 'L' must be from an expression of a compatible type (got 'M') +AsIs-Resolve.dfy(94,16): Error: type cast to reference type 'RefSyn' must be from an expression of a compatible type (got 'M') +AsIs-Resolve.dfy(100,12): Error: type cast to reference type 'K' must be from an expression of a compatible type (got 'M?') +AsIs-Resolve.dfy(101,12): Error: type cast to reference type 'L' must be from an expression of a compatible type (got 'M?') +AsIs-Resolve.dfy(103,13): Error: type cast to reference type 'RefSyn' must be from an expression of a compatible type (got 'M?') +AsIs-Resolve.dfy(109,16): Error: type cast to reference type 'K?' must be from an expression of a compatible type (got 'M') +AsIs-Resolve.dfy(110,16): Error: type cast to reference type 'L?' must be from an expression of a compatible type (got 'M') +AsIs-Resolve.dfy(117,13): Error: type cast to reference type 'K?' must be from an expression of a compatible type (got 'M?') +AsIs-Resolve.dfy(118,13): Error: type cast to reference type 'L?' must be from an expression of a compatible type (got 'M?') +AsIs-Resolve.dfy(128,11): Error: type cast to reference type 'M' must be from an expression of a compatible type (got 'K') +AsIs-Resolve.dfy(129,11): Error: type cast to reference type 'M' must be from an expression of a compatible type (got 'L') +AsIs-Resolve.dfy(130,12): Error: type cast to reference type 'M' must be from an expression of a compatible type (got 'RefSyn') +AsIs-Resolve.dfy(137,12): Error: type cast to reference type 'M?' must be from an expression of a compatible type (got 'K') +AsIs-Resolve.dfy(138,12): Error: type cast to reference type 'M?' must be from an expression of a compatible type (got 'L') +AsIs-Resolve.dfy(139,13): Error: type cast to reference type 'M?' must be from an expression of a compatible type (got 'RefSyn') +AsIs-Resolve.dfy(148,12): Error: type cast to reference type 'M' must be from an expression of a compatible type (got 'K?') +AsIs-Resolve.dfy(149,12): Error: type cast to reference type 'M' must be from an expression of a compatible type (got 'L?') +AsIs-Resolve.dfy(150,13): Error: type cast to reference type 'M' must be from an expression of a compatible type (got 'RefSyn?') +AsIs-Resolve.dfy(157,13): Error: type cast to reference type 'M?' must be from an expression of a compatible type (got 'K?') +AsIs-Resolve.dfy(158,13): Error: type cast to reference type 'M?' must be from an expression of a compatible type (got 'L?') +AsIs-Resolve.dfy(159,14): Error: type cast to reference type 'M?' must be from an expression of a compatible type (got 'RefSyn?') +AsIs-Resolve.dfy(183,11): Error: type test for type 'A' must be from an expression assignable to it (got 'M') +AsIs-Resolve.dfy(185,11): Error: type cast to reference type 'C<(int, real)>' must be from an expression of a compatible type (got 'M') +AsIs-Resolve.dfy(193,24): Error: type test for type 'List' must be from an expression assignable to it (got 'List') +AsIs-Resolve.dfy(196,14): Error: integer literal used as if it had type real +AsIs-Resolve.dfy(201,19): Error: type test for type 'VeryShortList' must be from an expression assignable to it (got 'VeryShortList') +AsIs-Resolve.dfy(204,18): Error: type test for type 'Stream' must be from an expression assignable to it (got 'Stream') +AsIs-Resolve.dfy(211,11): Error: type test for type 'real -> nat' must be from an expression assignable to it (got 'int -> nat') +AsIs-Resolve.dfy(212,11): Error: type test for type 'int -> real' must be from an expression assignable to it (got 'int -> nat') +AsIs-Resolve.dfy(213,11): Error: type test for type 'int -> Odd' must be from an expression assignable to it (got 'int -> nat') +AsIs-Resolve.dfy(220,11): Error: type test for type 'int ~> real' must be from an expression assignable to it (got 'int ~> nat') +AsIs-Resolve.dfy(221,11): Error: type test for type 'real --> nat' must be from an expression assignable to it (got 'int ~> nat') +AsIs-Resolve.dfy(229,15): Error: type test for type 'object' must be from an expression assignable to it (got 'T') +AsIs-Resolve.dfy(230,18): Error: type test for type 'array' must be from an expression assignable to it (got 'array') +AsIs-Resolve.dfy(231,18): Error: type test for type 'array' must be from an expression assignable to it (got 'array') +AsIs-Resolve.dfy(232,16): Error: type test for type 'T' must be from an expression assignable to it (got 'U') +AsIs-Resolve.dfy(234,16): Error: type test for type 'object' must be from an expression assignable to it (got 'U') +AsIs-Resolve.dfy(235,16): Error: type test for type 'object?' must be from an expression assignable to it (got 'U') +AsIs-Resolve.dfy(238,20): Error: type test for type 'U' must be from an expression assignable to it (got 'object') +AsIs-Resolve.dfy(247,18): Error: type test for type 'array' must be from an expression assignable to it (got 'array') +AsIs-Resolve.dfy(248,18): Error: type test for type 'array' must be from an expression assignable to it (got 'array') +AsIs-Resolve.dfy(270,12): Error: an expression of type 'D' is not run-time checkable to be a 'F' +AsIs-Resolve.dfy(273,12): Error: an expression of type 'T' is not run-time checkable to be a 'I' +AsIs-Resolve.dfy(280,12): Error: an expression of type 'D' is not run-time checkable to be a 'F' +AsIs-Resolve.dfy(283,12): Error: an expression of type 'T' is not run-time checkable to be a 'I' +AsIs-Resolve.dfy(306,11): Error: an expression of type 'object' is not run-time checkable to be a 'TriviallyObject' +AsIs-Resolve.dfy(308,21): Error: an expression of type 'object' is not run-time checkable to be a 'TriviallyObject' +72 resolution/type errors detected in AsIs-Resolve.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy index 86fd6423aa0..49ecc175b51 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --type-system-refresh --general-traits=datatype --general-newtypes "%s" > "%t" +// RUN: %exits-with 2 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" method IsBasicTypes(a0: bool, a1: char, a2: int, a3: bv7, a4: bv13, a5: ORDINAL, a6: real) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy.expect index d71b817f678..23eab5b482e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-SimplifiedExpanded-Resolve.dfy.expect @@ -33,26 +33,26 @@ AsIs-SimplifiedExpanded-Resolve.dfy(71,16): Error: type conversion to an int-bas AsIs-SimplifiedExpanded-Resolve.dfy(72,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got bool) AsIs-SimplifiedExpanded-Resolve.dfy(73,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got bool) AsIs-SimplifiedExpanded-Resolve.dfy(74,16): Error: type conversion to an ORDINAL type is allowed only from numeric and bitvector types, char, and ORDINAL (got bool) -AsIs-SimplifiedExpanded-Resolve.dfy(75,16): Error: type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got bool) +AsIs-SimplifiedExpanded-Resolve.dfy(75,16): Error: type conversion to real is allowed only from numeric-based types (got bool) AsIs-SimplifiedExpanded-Resolve.dfy(77,16): Error: type cast to type 'bool' must be from an expression of a compatible type (got 'char') AsIs-SimplifiedExpanded-Resolve.dfy(80,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got char) AsIs-SimplifiedExpanded-Resolve.dfy(81,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got char) AsIs-SimplifiedExpanded-Resolve.dfy(82,16): Error: type conversion to an ORDINAL type is allowed only from numeric and bitvector types, char, and ORDINAL (got char) -AsIs-SimplifiedExpanded-Resolve.dfy(83,16): Error: type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got char) +AsIs-SimplifiedExpanded-Resolve.dfy(83,16): Error: type conversion to real is allowed only from numeric-based types (got char) AsIs-SimplifiedExpanded-Resolve.dfy(85,16): Error: type cast to type 'bool' must be from an expression of a compatible type (got 'int') AsIs-SimplifiedExpanded-Resolve.dfy(93,16): Error: type cast to type 'bool' must be from an expression of a compatible type (got 'bv7') AsIs-SimplifiedExpanded-Resolve.dfy(94,16): Error: type conversion to a char type is allowed only from numeric and bitvector types, char, and ORDINAL (got bv7) AsIs-SimplifiedExpanded-Resolve.dfy(98,16): Error: type conversion to an ORDINAL type is allowed only from numeric and bitvector types, char, and ORDINAL (got bv7) -AsIs-SimplifiedExpanded-Resolve.dfy(99,16): Error: type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got bv7) +AsIs-SimplifiedExpanded-Resolve.dfy(99,16): Error: type conversion to real is allowed only from numeric-based types (got bv7) AsIs-SimplifiedExpanded-Resolve.dfy(101,16): Error: type cast to type 'bool' must be from an expression of a compatible type (got 'bv13') AsIs-SimplifiedExpanded-Resolve.dfy(102,16): Error: type conversion to a char type is allowed only from numeric and bitvector types, char, and ORDINAL (got bv13) AsIs-SimplifiedExpanded-Resolve.dfy(106,16): Error: type conversion to an ORDINAL type is allowed only from numeric and bitvector types, char, and ORDINAL (got bv13) -AsIs-SimplifiedExpanded-Resolve.dfy(107,16): Error: type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got bv13) +AsIs-SimplifiedExpanded-Resolve.dfy(107,16): Error: type conversion to real is allowed only from numeric-based types (got bv13) AsIs-SimplifiedExpanded-Resolve.dfy(109,16): Error: type cast to type 'bool' must be from an expression of a compatible type (got 'ORDINAL') AsIs-SimplifiedExpanded-Resolve.dfy(110,16): Error: type conversion to a char type is allowed only from numeric and bitvector types, char, and ORDINAL (got ORDINAL) AsIs-SimplifiedExpanded-Resolve.dfy(112,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got ORDINAL) AsIs-SimplifiedExpanded-Resolve.dfy(113,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got ORDINAL) -AsIs-SimplifiedExpanded-Resolve.dfy(115,16): Error: type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got ORDINAL) +AsIs-SimplifiedExpanded-Resolve.dfy(115,16): Error: type conversion to real is allowed only from numeric-based types (got ORDINAL) AsIs-SimplifiedExpanded-Resolve.dfy(117,16): Error: type cast to type 'bool' must be from an expression of a compatible type (got 'real') AsIs-SimplifiedExpanded-Resolve.dfy(118,16): Error: type conversion to a char type is allowed only from numeric and bitvector types, char, and ORDINAL (got real) AsIs-SimplifiedExpanded-Resolve.dfy(120,16): Error: type conversion to a bitvector-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got real) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Verify.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Verify.dfy new file mode 100644 index 00000000000..4b52bf1f100 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Verify.dfy @@ -0,0 +1,15 @@ +// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %diff "%s.expect" "%t" + + +type pos = x | 1 <= x witness 3 + +method ImplicitConversions(f: bool ~> nat) { + var g: bool ~> int := f; + var h: bool ~> pos := f; // error (case in point: f(true) may be 0) +} + +method CompareRegression(f: bool ~> nat) { + var g := f as bool ~> int; + var h := f as bool ~> pos; // error (case in point: f(true) may be 0) +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Verify.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Verify.dfy.expect new file mode 100644 index 00000000000..82af4c06f3e --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs-Verify.dfy.expect @@ -0,0 +1,4 @@ +AsIs-Verify.dfy(9,24): Error: value of expression (of type 'bool ~> nat') is not known to be an instance of type 'bool ~> pos' +AsIs-Verify.dfy(14,13): Error: value of expression (of type 'bool ~> nat') is not known to be an instance of type 'bool ~> pos' + +Dafny program verifier finished with 1 verified, 2 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs.dfy index 37fe92d26ee..248672a239e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIs.dfy @@ -1,8 +1,8 @@ // RUN: %testDafnyForEachResolver --expect-exit-code=4 --refresh-exit-code=2 "%s" -trait A { } -trait B { } +trait A extends object { } +trait B extends object { } trait C extends B { } class K extends object, B { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIsAgain.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIsAgain.dfy index 97e04d48e9a..6c3bc78bcff 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIsAgain.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AsIsAgain.dfy @@ -1,8 +1,8 @@ // RUN: %testDafnyForEachResolver --expect-exit-code=4 "%s" // This file is like AsIs.dfy, but has explicit type casts in AssignBackAndForth, as required by the new type system. -trait A { } -trait B { } +trait A extends object { } +trait B extends object { } trait C extends B { } class K extends object, B { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AssumptionVariables0.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AssumptionVariables0.dfy.expect index e659c37c127..dc233357e90 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AssumptionVariables0.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/AssumptionVariables0.dfy.expect @@ -1,5 +1,5 @@ AssumptionVariables0.dfy(7,31): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a0 && " -AssumptionVariables0.dfy(8,44): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a2 && " +AssumptionVariables0.dfy(8,35): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a2 && " AssumptionVariables0.dfy(16,7): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a3 && " AssumptionVariables0.dfy(18,7): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a3 && " AssumptionVariables0.dfy(28,7): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a0 && " @@ -7,7 +7,7 @@ AssumptionVariables0.dfy(32,7): Error: there may be at most one assignment to an AssumptionVariables0.dfy(54,11): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a0 && " AssumptionVariables0.dfy(62,39): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a0 && " AssumptionVariables0.dfy(70,17): Error: there may be at most one assignment to an assumption variable, the RHS of which must match the expression "a0 && " -AssumptionVariables0.dfy(106,45): Error: RHS (of type int) not assignable to LHS (of type bool) +AssumptionVariables0.dfy(106,48): Error: integer literal used as if it had type bool AssumptionVariables0.dfy(116,28): Error: assumption variable must be of type 'bool' AssumptionVariables0.dfy(117,22): Error: assumption variable must be ghost 12 resolution/type errors detected in AssumptionVariables0.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BitvectorResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BitvectorResolution.dfy index 24cd8f70b82..cfbde07b109 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BitvectorResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BitvectorResolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module LiteralSizes { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismResolution.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismResolution.dfy.refresh.expect index c349cc75f8f..380c5ccf77a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismResolution.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismResolution.dfy.refresh.expect @@ -65,7 +65,7 @@ BoundedPolymorphismResolution.dfy(355,39): Error: type bound for type parameter BoundedPolymorphismResolution.dfy(378,15): Error: type parameters are not allowed to be renamed from the names given in the datatype in the module being refined (expected 'X', found 'Y') BoundedPolymorphismResolution.dfy(399,11): Error: type parameters are not allowed to be renamed from the names given in the type in the module being refined (expected 'X', found 'Z') BoundedPolymorphismResolution.dfy(401,12): Error: type parameters are not allowed to be renamed from the names given in the class in the module being refined (expected 'X', found 'Y') -BoundedPolymorphismResolution.dfy[YY](394,28): Error: character literal used as if it had type int +BoundedPolymorphismResolution.dfy[YY](394,28): Error: character literal used as if it had type X BoundedPolymorphismResolution.dfy(425,4): Error: actual type argument 'real' for formal type parameter 'G' must satisfy the type bound 'GoodTrait' BoundedPolymorphismResolution.dfy(425,5): Error: actual type argument 'real' for formal type parameter 'G' must satisfy the type bound 'GoodTrait' 70 resolution/type errors detected in BoundedPolymorphismResolution.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismVerification.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismVerification.dfy index f2322ccf4f4..aa875ad8afc 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismVerification.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/BoundedPolymorphismVerification.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --type-system-refresh --general-traits=datatype "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=true --general-traits=datatype "%s" > "%t" // RUN: %diff "%s.expect" "%t" module As { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ByMethodResolution.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ByMethodResolution.dfy.expect index b0220aed8d0..a7475b3bb0f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ByMethodResolution.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ByMethodResolution.dfy.expect @@ -1,6 +1,6 @@ ByMethodResolution.dfy(17,6): Error: number of return parameters does not match declaration (found 2, expected 1) -ByMethodResolution.dfy(25,4): Error: Method return value mismatch (expected real, got bv9) -ByMethodResolution.dfy(24,6): Error: RHS (of type int) not assignable to LHS (of type real) +ByMethodResolution.dfy(25,4): Error: RHS (of type bv9) not assignable to LHS (of type real) +ByMethodResolution.dfy(24,9): Error: integer literal used as if it had type real ByMethodResolution.dfy(63,14): Error: a call to a ghost function is allowed only in specification contexts (consider declaring the function without the 'ghost' keyword) ByMethodResolution.dfy(64,15): Error: a call to a ghost predicate is allowed only in specification contexts (consider declaring the predicate without the 'ghost' keyword) ByMethodResolution.dfy(65,15): Error: a call to a twostate function is allowed only in specification contexts diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/CoResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/CoResolution.dfy index 0827a79e560..6159af42824 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/CoResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/CoResolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-axioms "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-axioms --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module TestModule { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.dfy new file mode 100644 index 00000000000..e2dfa6e1db0 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.dfy @@ -0,0 +1,536 @@ +// RUN: %testDafnyForEachCompiler "%s" + + +// The tests in this file are designed to run through the compiler. They contain +// program snippets that are tricky to compile or whose compilation once was buggy. + +module OnceBuggy { + datatype MyDt = Nil | Cons(T, MyDt) + + method M(x: MyDt) + { + match (x) { + case Cons(head, tail) => + var y: int := head; + case Nil => + } + } +} + +// -------------------------------------------------- + +module CoRecursion { + codatatype Stream = More(head: T, rest: Stream) + + function AscendingChain(n: int): Stream + { + More(n, AscendingChain(n+1)) + } + + datatype List = Nil | Cons(car: T, cdr: List) + + function Prefix(n: nat, s: Stream): List + { + if n == 0 then Nil else + Cons(s.head, Prefix(n-1, s.rest)) + } + + class Cell { var data: int } + + // When run, the following method should print + // 400 + // 320 + // 40 + // 41 + // 42 + // 9 + // 9 + method TestMain() { + var m := 17; + var cell := new Cell; + cell.data := 40; + var mr := More(400, More(320, AscendingChain(cell.data))); + m := 30; + cell.data := 60; + var l := Prefix(5, mr); + while (l != Nil) + decreases l + { + match (l) { case Cons(x,y) => } + print l.car, "\n"; + l := l.cdr; + } + var nio := OneLess(0, 10); + print nio, "\n"; + nio := OneLess'(0, 10); + print nio, "\n"; + } + + method OneLess(lo: int, hi: int) returns (m: int) + requires lo < hi + // This method ensures m == hi - 1, but we don't care to prove it + decreases hi - lo + { + if y {:nowarn} :| lo < y < hi { + m := OneLess(y, hi); + } else { + m := lo; + } + } + + method OneLess'(lo: int, hi: int) returns (m: int) + requires lo < hi + // This method ensures m == hi - 1, but we don't care to prove it + decreases hi - lo + { + if { + case y {:nowarn} :| lo < y < hi => + m := OneLess'(y, hi); + case lo+1 < hi => + m := OneLess'(lo+1, hi); + case lo + 1 == hi => + m := lo; + } + } +} + +abstract module S { + class C { + var f: int + method m() + } +} + +module T refines S { + class C ... { + constructor () { } + method m() { + print "in T.C.m()"; + } + } +} +module A { + import X = T + import Y = T + import Z = T + method run() { + var x := new X.C(); + x.m(); + var y := new Y.C(); + y.m(); + var z := new Z.C(); + z.m(); + } +} + +method NotMain() { + A.run(); +} + + +abstract module S1 { + import B : T + method do() +} + +module T1 refines S1 { + method do() { + var x := 3; + } +} +abstract module A1 { + import X : T1 + method run() { + X.do(); + var x := new X.B.C(); + x.m(); + } +} + +// ----- keyword escapes (once buggy) ----- + +module M { + datatype fixed = A | B + function F(): fixed + { + A + } + class public { + constructor() { } + var private: int const namespace: int const fallthrough: int const try: int + } +} + +method Caller() { + var p := new M.public(); + var x := p.private + p.namespace + p.fallthrough + p.try; +} + +// ----- digits-identifiers for destructors ----- + +datatype Tuple = Pair(0: T, 1: U, r: int, s': int) + +method DigitsIdents(t: Tuple>) +{ + var x: int := t.0; + var y: bool := t.1.1; + var z: int := t.r + t.1.r + t.1.s'; +} + +class DigitsClass { + var 7: bool + method M(c: DigitsClass) + { + var x: int := if this.7 then 7 else if c.7 then 8 else 9; + } +} + +// Should not get errors about methods or functions with empty bodies +// if they're marked with an :axiom attribute +ghost method {:axiom} m_nobody() returns (y:int) + ensures y > 5 + +lemma {:axiom} l_nobody() returns (y:int) + ensures y > 5 + +ghost function {:axiom} f_nobody():int + ensures f_nobody() > 5 + +// Make sure the lemma created for opaque functions doesn't produce compiler errors +ghost function {:opaque} hidden():int +{ + 7 +} + +method hidden_test() +{ + reveal hidden(); + assert hidden() == 7; +} + +// ----- LetExpr with ghosts and in ghost contexts ----- + +module GhostLetExpr { + method M() { + ghost var y := *; + var x := *; + var g := G(x, y); + ghost var h := var ta := F(); 5; + var j := ghost var tb := F(); 5; + assert h == j; + } + + ghost function F(): int + { 5 } + + function G(x: int, ghost y: int): int + { assert y == y; x } + + datatype Dt = MyRecord(a: int, ghost b: int) + + method P(dt: Dt) { + match dt { + case MyRecord(aa, bb) => + ghost var z := bb + F(); + ghost var t0 := var y := z; z + 3; + ghost var t1 := ghost var y := z; z + 3; + var t2; t2 := ghost var y := z; aa + 3; + } + } + + function FM(): int + { + ghost var xyz := F(); + G(5, xyz) + } +} + +class DigitUnderscore_Names { + // the following would be the same integers, but they are different fields + var 0_1_0: int + var 010: int + var 10: int + // ... as we see here: + method M() + modifies this + { + this.0_1_0 := 007; + this.010 := 000_008; + this.10 := 0x0000_0009; + assert this.0_1_0 == 00_07.0_0 as int && this.010 == 8 && this.10 == 9; + this.10 := 20; + } +} + +// ------------------------------------------------------------------ + +method Main() +{ + CoRecursion.TestMain(); + EqualityTests.TestMain(); + TypeInstantiations.TestMain(); + TailRecursionWhereTypeParametersChange.TestMain(); + GeneralMaps.Test(); + Cardinalities.Test(); + AltLoop.Test(); +} + +// ------------------------------------------------------------------ + +module EqualityTests { + class C { + } + + method TestMain() + { + // regression tests: + var a: C?, b: C? := null, null; + if a == null { + print "a is null\n"; + } + if a != null { + print "a is not null\n"; + } + if a == b { + print "a and b are equal\n"; + } + if a != b { + print "a and b are not equal\n"; + } + + var H := new real[10]; + ArrayTests(H); + } + + method ArrayTests(H: array?) + { + var G := new int[10]; + if G as object == H { // this comparison is allowed in Dafny, but requires a cast in C# + print "this would be highly suspicious\n"; + } + if G == H as object? { // this comparison is allowed in Dafny, but requires a cast in C# + print "this would be highly suspicious\n"; + } + if G as object? != H { // this comparison is allowed in Dafny, but requires a cast in C# + print "? good world order\n"; + } + if G != H as object? { // this comparison is allowed in Dafny, but requires a cast in C# + print "good world order ?\n"; + } + if null == H { + print "given array is null\n"; + } + if null != H { + print "given array is non-null\n"; + } + } +} + +// ------------------------------------------------- +// Once buggy + +method N() +{ + var z: nat :| true; + assert 0 <= z; +} + +// ------------------------------------------------- + +class DigitUnderscore_Names_Functions_and_Methods { + ghost function 70(): int { 80 } + lemma 120() + ensures this.70() == 80 + { + } + + const 90 := () => 92 + method 567(y: int) { + var m := this.90; + var k := this.90(); + assert k == 92; + if 0 < y { + ghost var g := this.70(); + this.567(y-1); + assert g == 80; + } + } + + constructor 20_0(x: int) + { + new; + var u := this.88; + assert u == DigitUnderscore_Names_Functions_and_Methods.88; + } + + static const 88: bool + + method 498() { + var p := new DigitUnderscore_Names_Functions_and_Methods.20_0(200); + p.567(100); + } + + least predicate 500(y: int) + { + y == 0 || this.500(y-1) + } + + least lemma 5_0_0(y: int) + requires this.500(y) + ensures 0 <= y + { + } + lemma Another(k: ORDINAL, y: int) + requires this.500#[k](y) + ensures 0 <= y + { + this.5_0_0#[k](y); + } + + const x' := 3.0 // the prime in the name previously compiled incorrectly + method Regression(u: real) returns (v: real) + { + v := u * x'; + } +} + +// ------------------------------------------------- +// once buggy for method calls + +module TypeInstantiations { + function F(): int { 56 } + function H(g: G): int { 57 } + method M() returns (r: int) { r := 100; } + method N(g: G) returns (r: int) { r := 101; } + + class GenCl { + static function Static(): int { 58 } + function Inst(): int { 59 } + static method Ms() returns (r: int) { r := 102; } + method Mi() returns (r: int) { r := 103; } + } + + method TestMain() { + var x := F(); + var ch: char := *; + var y := H(ch); + print x, " ", y, "\n"; + + var a0 := GenCl.Static(); + var cl := new GenCl; + var a1 := cl.Inst(); + print a0, " ", a1, "\n"; + + x := M(); + y := N(ch); + print x, " ", y, "\n"; + + a0 := GenCl.Ms(); + a1 := cl.Mi(); + print a0, " ", a1, "\n"; + } +} + +// ------------------------------------------------- +// once buggy -- tail recursion where type parameters change + +module TailRecursionWhereTypeParametersChange { + method TestMain() { + Compute(5); // expected output: 0.0 False False + } + + // Ostensibly, this looks like a tail recursive method. However, a + // recursive call that changes the type arguments cannot be compiled + // using a tail-recursive goto. Therefore, this method is rejected + // as tail recursive (which means that, for a large enough "n", it + // can run out of stack space). + method Compute(n: nat) + { + if n == 0 { + print "\n"; + } else if n % 2 == 0 { + Compute(n-1); + } else { + var g: G := *; + print g, " "; + Compute(n-1); + } + } +} + +// ------------------------------------------------- + +module GeneralMaps { + method Test() { + var m := map x {:nowarn} | 2 <= x < 6 :: x+1; + PrintMap(m, 0, 20); + m := map y {:nowarn} | 2 <= y < 6 :: y+1 := y+3; + PrintMap(m, 0, 20); + m := map y {:nowarn} | 2 <= y < 6 :: y+1 := 10; + PrintPairs(m.Items, 0, 20); + print m.Keys, "\n"; + print m.Values, "\n"; + } + + method PrintMap(m: map, lo: int, hi: int) + requires lo <= hi + { + print |m|, ": map["; + var sep := ""; + for i := lo to hi { + if i in m.Keys { + print sep, i, " := ", m[i]; + sep := ", "; + } + } + print "]\n"; + } + + method PrintPairs(pairs: set<(int, int)>, lo: int, hi: int) + requires lo <= hi + { + print |pairs|, ": {"; + var sep := ""; + for i := lo to hi { + for j := lo to hi { + if (i, j) in pairs { + print sep, (i, j); + sep := ", "; + } + } + } + print "}\n"; + } +} + +// ------------------------------------------------- + +module Cardinalities { + method Test() { + var s := "hello"; + var q := [0, 2, 4]; + var t := {s}; + var m := multiset{3, 5, 3}; + var p := map[false := s, true := s]; + print |s|, " ", |q|, " ", |t|, " ", |m|, " ", |p|, "\n"; + } +} + +// ------------------------------------------------- + +module AltLoop { + method Test() { + var m, n := 5, 2; + while + decreases m + n + { + case 0 < n => + print n, " "; + n := n - 1; + case n == 0 < m => + print m, " "; + m := m - 1; + } + print "\n"; + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.dfy.expect new file mode 100644 index 00000000000..65d2805780c --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.dfy.expect @@ -0,0 +1,24 @@ +400 +320 +40 +41 +42 +9 +9 +a is null +a and b are equal +? good world order +good world order ? +given array is non-null +56 57 +58 59 +100 101 +102 103 +0.0 false false +4: map[2 := 3, 3 := 4, 4 := 5, 5 := 6] +4: map[3 := 5, 4 := 6, 5 := 7, 6 := 8] +4: {(3, 10), (4, 10), (5, 10), (6, 10)} +{3, 4, 5, 6} +{10} +5 3 1 3 2 +2 1 5 4 3 2 1 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.legacy.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.legacy.dfy index 6b61ef2e4e4..2fad9d8efb7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.legacy.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Compilation.legacy.dfy @@ -1,5 +1,5 @@ // NONUNIFORM: /autoTriggers:0 not supported by new CLI -// RUN: %dafny /compile:3 /deprecation:0 /autoTriggers:0 "%s" > "%t" +// RUN: %dafny /compile:3 /deprecation:0 /autoTriggers:0 /typeSystemRefresh:0 /generalNewtypes:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" // The tests in this file are designed to run through the compiler. They contain diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Comprehensions.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Comprehensions.dfy index b005967f6c0..4434c9e23ad 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Comprehensions.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Comprehensions.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method M() diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ComprehensionsNewSyntax.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ComprehensionsNewSyntax.dfy index 7b5da3a79bd..a93578c6fe9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ComprehensionsNewSyntax.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ComprehensionsNewSyntax.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method M() diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Constant.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Constant.dfy index 557f0bffc13..ae03aaf229d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Constant.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Constant.dfy @@ -89,7 +89,7 @@ class NoRHS { // ---------- traits -------------------- -trait Trait { +trait Trait extends object { const x0: Six const x1: Six := 7 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ConstantErrors.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ConstantErrors.dfy index c01c02a1ca0..02fa5a98e84 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ConstantErrors.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ConstantErrors.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-axioms "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-axioms --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module A { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Corecursion.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Corecursion.dfy index a67a8ae0f41..72f510b2e37 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Corecursion.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Corecursion.dfy @@ -1,5 +1,5 @@ -// RUN: %testDafnyForEachResolver --expect-exit-code=4 "%s" -- --allow-deprecation - +// RUN: %testDafnyForEachResolver --expect-exit-code=4 "%s" -- --type-system-refresh=false --general-newtypes=false +// NOTE: This test fails with the new resolver, because Cons(n, A(...)) in function B is inferred to have type Stream. This should be fixed. // -------------------------------------------------- @@ -12,13 +12,13 @@ module CoRecursion { } ghost function AscendingChainAndRead(n: nat): Stream - reads null; // with a reads clause, this function is not a co-recursive function + reads null // with a reads clause, this function is not a co-recursive function { More(n, AscendingChainAndRead(n+1)) // error: cannot prove termination } ghost function AscendingChainAndPostcondition(n: nat): Stream - ensures false; // with an ensures clause, this function is not a co-recursive function + ensures false // with an ensures clause, this function is not a co-recursive function { More(n, AscendingChainAndPostcondition(n+1)) // error: cannot prove termination } @@ -38,12 +38,12 @@ module CoRecursionNotUsed { codatatype Stream = More(T, Stream) ghost function F(s: Stream, n: nat): Stream - decreases n, true; + decreases n, true { G(s, n) } ghost function G(s: Stream, n: nat): Stream - decreases n, false; + decreases n, false { if n == 0 then s else Tail(F(s, n-1)) } @@ -105,8 +105,8 @@ module MixRecursiveAndCorecursive { H(n) } ghost function H(n: nat): Stream - requires n != 0; - decreases n, 0; + requires n != 0 + decreases n, 0 { G(n-1).tail } @@ -120,8 +120,8 @@ module MixRecursiveAndCorecursive { Y(n) } ghost function Y(n: nat): Stream - requires n != 0; - decreases n, 0; + requires n != 0 + decreases n, 0 { X(n-1) } @@ -133,7 +133,7 @@ module FunctionSCCsWithMethods { codatatype Stream = Cons(head: T, tail: Stream) lemma M(n: nat) - decreases n, 0; + decreases n, 0 { if n != 0 { var p := Cons(10, F(n-1)); @@ -141,7 +141,7 @@ module FunctionSCCsWithMethods { } ghost function F(n: nat): Stream - decreases n; + decreases n { M(n); // the following call to F is not considered co-recursive, because the SCC contains a method @@ -155,14 +155,14 @@ module FunctionSCCsWithMethods { } ghost function H(): Stream - decreases 0; + decreases 0 { // the following call to G is not considered co-recursive, because the SCC contains a method Cons(5, G()) // error: cannot prove termination } lemma Lemma() - decreases 1; + decreases 1 { var h := H(); } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DatatypeUpdate.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DatatypeUpdate.dfy index 071fa9cfd8f..1303bfbf0f9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DatatypeUpdate.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DatatypeUpdate.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module NewSyntax { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy index eed09adb30c..516bb3b3614 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy @@ -459,3 +459,39 @@ module Exhaustiveness { assert false; // fine, since we never get here (which is known by the exhaustiveness property of datatypes) } } + + +module TypeInferenceTests { + datatype Result<+T> = Success(value: T) + + type MyReal = r: real | r != 0.7 + + method M(r: MyReal) { + var a := Success(r); // Result + var b := Result.Success(r); // Result + var c := Result.Success(r); // Result + var d := Result.Success(r); // Result + + var u: Result; // Result + u := Success(r); + var v: Result; // Result + v := Success(r); + var w: Result; // Result + w := Success(r); + + for i := 0 to 10 { + a, b, c, d, u, v, w := *, *, *, *, *, *, *; + } + if + case true => + assert a.value != 0.7; + assert b.value != 0.7; + assert d.value != 0.7; + assert u.value != 0.7; + assert w.value != 0.7; + case true => + assert c.value != 0.7; // error: the type of "c" is Result + case true => + assert v.value != 0.7; // error: the type of "c" is Result + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy.expect index 7c0f82a843e..8fb65f46cb9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Datatypes.dfy.expect @@ -12,5 +12,7 @@ Datatypes.dfy(349,4): Error: missing case in match expression: Nil Datatypes.dfy(356,7): Error: missing case in match expression: Cons(_, _) Datatypes.dfy(356,7): Error: missing case in match expression: Nil Datatypes.dfy(377,21): Error: RHS is not certain to look like the pattern 'AAA' +Datatypes.dfy(493,6): Error: assertion might not hold +Datatypes.dfy(495,6): Error: assertion might not hold -Dafny program verifier finished with 28 verified, 13 errors +Dafny program verifier finished with 29 verified, 15 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy index b0240d37082..8f17af199ce 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy @@ -24,7 +24,7 @@ module AA { method Q() { - assert (((map[]))) == (((((map[]))))); // 2 errors (but not 10 errors) + assert (((map[]))) == (((((map[]))))); // error: underspecified type (but not 10 errors) } } @@ -38,8 +38,8 @@ module BB { method B1() returns (s: seq) { var b := 10; // int var u: int := 30; - var t := [b, 20, u]; // seq - s := t; // error: type mismatch + var t := [b, 20, u]; // error: type mismatch + s := t; } method B2() returns (s: seq) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy.expect index d2714fa8123..1a1fec85217 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/DisplayExpressions.dfy.expect @@ -1,8 +1,8 @@ -DisplayExpressions.dfy(7,8): Error: the type of this variable is underspecified -DisplayExpressions.dfy(12,8): Error: the type of this variable is underspecified -DisplayExpressions.dfy(17,8): Error: the type of this variable is underspecified -DisplayExpressions.dfy(22,8): Error: the type of this variable is underspecified -DisplayExpressions.dfy(27,14): Error: the type of this expression is underspecified -DisplayExpressions.dfy(42,6): Error: RHS (of type seq) not assignable to LHS (of type seq) (covariant type parameter would require int <: byte) +DisplayExpressions.dfy(7,8): Error: the type ('map') of this variable is underspecified +DisplayExpressions.dfy(12,8): Error: the type ('multiset') of this variable is underspecified +DisplayExpressions.dfy(17,8): Error: the type ('seq') of this variable is underspecified +DisplayExpressions.dfy(22,8): Error: the type ('set') of this variable is underspecified +DisplayExpressions.dfy(27,14): Error: the type ('map') of this expression is underspecified +DisplayExpressions.dfy(41,13): Error: element type of seq display expected to be byte (got int) DisplayExpressions.dfy(74,18): Error: arguments must have comparable types (got seq and seq) 7 resolution/type errors detected in DisplayExpressions.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypes.dfy index d590b79cef0..70c2401d7bf 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypes.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-deprecation --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module A { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy index 5caedcc7d38..85afb1d3d33 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy @@ -35,7 +35,7 @@ module AAA { method Q(h: set) } - trait Trait { + trait Trait extends object { } // The following types all take (==) arguments diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy.expect index d26388e10dd..fe3ec867fce 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/EqualityTypesModuleExports.dfy.expect @@ -42,10 +42,10 @@ EqualityTypesModuleExports.dfy(249,7): Error: to be a refinement of abstract typ EqualityTypesModuleExports.dfy(265,12): Error: type parameter (A) passed to type S must support equality (got GGG.Opa') (perhaps try declaring abstract type 'Opa'' on line 243 as 'Opa'(==)', which says it can only be instantiated with a type that supports equality) EqualityTypesModuleExports.dfy(266,12): Error: type parameter (A) passed to type S must support equality (got GGG.Syn') EqualityTypesModuleExports.dfy(267,12): Error: type parameter (A) passed to type S must support equality (got GGG.Sub') -EqualityTypesModuleExports.dfy(284,7): Error: == can only be applied to expressions of types that support equality (got WWW0.XT) -EqualityTypesModuleExports.dfy(287,7): Error: == can only be applied to expressions of types that support equality (got WWW0.YT) -EqualityTypesModuleExports.dfy(290,7): Error: == can only be applied to expressions of types that support equality (got WWW0.ZT) -EqualityTypesModuleExports.dfy(293,7): Error: == can only be applied to expressions of types that support equality (got WWW0.WT) +EqualityTypesModuleExports.dfy(284,7): Error: == can only be applied to expressions of types that support equality (got XT) +EqualityTypesModuleExports.dfy(287,7): Error: == can only be applied to expressions of types that support equality (got YT) +EqualityTypesModuleExports.dfy(290,7): Error: == can only be applied to expressions of types that support equality (got ZT) +EqualityTypesModuleExports.dfy(293,7): Error: == can only be applied to expressions of types that support equality (got WT) EqualityTypesModuleExports.dfy(318,7): Error: type 'A' declared as supporting equality, but the RHS type (QQQ1.Syn) might not EqualityTypesModuleExports.dfy(333,7): Error: type 'ExportedType' declared as supporting equality, but the RHS type (PrivateType) might not (perhaps try declaring type parameter 'A' on line 333 as 'A(==)', which says it can only be instantiated with a type that supports equality) EqualityTypesModuleExports.dfy(381,4): Error: == can only be applied to expressions of types that support equality (got List) (perhaps try declaring type parameter 'A' on line 379 as 'A(==)', which says it can only be instantiated with a type that supports equality) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy index 183a88bae30..c893a86ce6b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy @@ -147,7 +147,7 @@ module ClientOfErroneousModule5 { module ClientOfErroneousModule6 { import ModuleWithErrors - trait EverythingHasTheSameName { } + trait EverythingHasTheSameName extends object { } class EverythingHasTheSameName { } // error: duplicate name datatype EverythingHasTheSameName = Y // error: duplicate name } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy.expect index 0c27c352632..39c9a7598ff 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ErrorsInRelatedModules.dfy.expect @@ -5,8 +5,8 @@ ErrorsInRelatedModules.dfy(34,29): Error: Type or type parameter is not declared ErrorsInRelatedModules.dfy(34,29): Error: Type or type parameter is not declared in this scope: UndeclaredType (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) ErrorsInRelatedModules.dfy(59,21): Error: module I does not exist (position 1 in path Middle.I) ErrorsInRelatedModules.dfy(65,27): Error: Type or type parameter is not declared in this scope: UndeclaredType (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) -ErrorsInRelatedModules.dfy(129,17): Error: RHS (of type bool) not assignable to LHS (of type int) -ErrorsInRelatedModules.dfy(138,17): Error: RHS (of type bool) not assignable to LHS (of type int) +ErrorsInRelatedModules.dfy(129,20): Error: boolean literal used as if it had type int +ErrorsInRelatedModules.dfy(138,20): Error: boolean literal used as if it had type int ErrorsInRelatedModules.dfy(151,8): Error: duplicate name of top-level declaration: EverythingHasTheSameName ErrorsInRelatedModules.dfy(150,8): Related location ErrorsInRelatedModules.dfy(152,11): Error: duplicate name of top-level declaration: EverythingHasTheSameName diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForLoops-Resolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForLoops-Resolution.dfy index de18a83c958..ea154f5b173 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForLoops-Resolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForLoops-Resolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Tests { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForallStmt.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForallStmt.dfy index 4fdf67393f1..c5f901824e8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForallStmt.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ForallStmt.dfy @@ -72,7 +72,7 @@ ghost function Pred(x: int, y: int): bool method M0(S: set) modifies S ensures forall o :: o in S ==> o.data == 85 - ensures forall o :: o !in S && !fresh(o) ==> o.data == old(o.data) + ensures forall o :: o !in S && o != null && !fresh(o) ==> o.data == old(o.data) { forall s | s in S { s.data := 85; diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy index 38df2d5f333..6a2853429b8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy @@ -561,6 +561,71 @@ module SimpleNewtypeWitness { newtype H = A ghost witness 13 // error: 13 does not satisfy constraint } +module StringLiterals { + newtype LowerCase = ch: char | 'a' <= ch <= 'z' witness 'a' + newtype MyChar = ch: char | 'a' <= ch <= 'z' || ch == '\n' witness 'a' + newtype MyString = s: seq | |s| < 5 + + method BadCharacters() { + if + case true => + var w0: MyString := ""; + case true => + var w1: MyString := "rs"; + case true => + var w2: MyString := ['r', 's']; + case true => + var w3: MyString := ['r', 'A']; // error: 'A' is not a MyChar + case true => + var w4: MyString := "rB"; // error: 'B' is not a MyChar + case true => + var w5: seq := ['r', 'C']; // error: 'C' is not a MyChar + case true => + var w6: seq := "rD"; // error: 'D' is not a MyChar + } + + method BadVerbatim() { + if + case true => + var w0: seq := @"r +s"; // error (on previous line): the newline is not a LowerCase + case true => + var w1: seq := @"r +s"; + case true => + var w2: MyString := @"r +Xs"; // error (on previous line): 'X' is not a MyChar + case true => + var w3: MyString := @"r +stuvxyz"; // error (on previous line): too long to be a MyString + case true => + var w4: seq := @" +abcdeABCDE"; + } + + method BadStringLength() { + if + case true => + var w0: MyString := "abcde"; // error: too long to be a MyString + case true => + var w1: MyString := ['r', 's', 't', 'u', 'v']; // error: too long to be a MyString + } + + method BadChar() { + if + case true => + var ch0: char := 'a'; + var ch1: LowerCase := 'a'; + var ch2: MyChar := 'a'; + case true => + var ch3: char := 'X'; + case true => + var ch4: LowerCase := 'Y'; // error: not a LowerCase + case true => + var ch5: MyChar := 'Z'; // error: not a MyChar + } +} + /* module RealConversions { method TestRealIsInt0(r: real) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy.expect index 643fdcb9ea3..c1af69a2ff6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GeneralNewtypeVerify.dfy.expect @@ -48,5 +48,16 @@ GeneralNewtypeVerify.dfy(541,15): Related location GeneralNewtypeVerify.dfy(555,10): Error: trying witness 0: result of operation might violate newtype constraint for 'A' GeneralNewtypeVerify.dfy(560,24): Error: result of operation might violate newtype constraint for 'A' GeneralNewtypeVerify.dfy(561,30): Error: result of operation might violate newtype constraint for 'A' +GeneralNewtypeVerify.dfy(578,32): Error: result of operation might violate newtype constraint for 'MyChar' +GeneralNewtypeVerify.dfy(580,26): Error: value does not satisfy the subset constraints of 'MyChar' +GeneralNewtypeVerify.dfy(582,35): Error: result of operation might violate newtype constraint for 'MyChar' +GeneralNewtypeVerify.dfy(584,29): Error: value does not satisfy the subset constraints of 'MyChar' +GeneralNewtypeVerify.dfy(590,32): Error: value does not satisfy the subset constraints of 'LowerCase' +GeneralNewtypeVerify.dfy(596,26): Error: value does not satisfy the subset constraints of 'MyChar' +GeneralNewtypeVerify.dfy(599,26): Error: result of operation might violate newtype constraint for 'MyString' +GeneralNewtypeVerify.dfy(609,26): Error: result of operation might violate newtype constraint for 'MyString' +GeneralNewtypeVerify.dfy(611,26): Error: result of operation might violate newtype constraint for 'MyString' +GeneralNewtypeVerify.dfy(623,28): Error: result of operation might violate newtype constraint for 'LowerCase' +GeneralNewtypeVerify.dfy(625,25): Error: result of operation might violate newtype constraint for 'MyChar' -Dafny program verifier finished with 40 verified, 48 errors +Dafny program verifier finished with 43 verified, 59 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAllocations-Resolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAllocations-Resolution.dfy index 82f164f6d36..ec529a22131 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAllocations-Resolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAllocations-Resolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // ------- A constructor-less class can be allocated as either ghost or non-ghost diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAutoInit.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAutoInit.dfy index fde58e68512..9749d89d3b1 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAutoInit.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostAutoInit.dfy @@ -3,7 +3,7 @@ module DeclaredTypes { - trait MaybeEmpty { } + trait MaybeEmpty extends object { } type GhostAutoInit = x: MaybeEmpty? | true ghost witness null type CompileAutoInit = MaybeEmpty? @@ -264,14 +264,14 @@ module FiftyShadesOfGhost { } method V(cell: LongCell) { - if m, n, x, y :| cell == LongGH(m, n, x, y) { // all 4 get bound to values + if m: G, n: G, x, y :| cell == LongGH(m, n, x, y) { // all 4 get bound to values // we're in a ghost context here GhostCallee(m, n, x, y); // all fine } } method W(cell: SmallCell) { - if m, x :| cell == SmallGH(m, x) { // all 2 get bound to values + if m: G, x :| cell == SmallGH(m, x) { // all 2 get bound to values // this is still a ghost context GhostCallee(m, m, x, x); // all fine } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy index 1ff851749b0..500c827439d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy @@ -98,7 +98,7 @@ module {:options "/functionSyntax:4"} Match { // the following match statement is ghost, because it directly mentions a ghost constructor match xy case D0(_) => - case G0 => r := 0; // error: assignment to r in a ghost context + case G0(_) => r := 0; // error: assignment to r in a ghost context case any => } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy.expect index 5aceb627740..971f96bedb7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/GhostDatatypeConstructors-Resolution.dfy.expect @@ -5,7 +5,7 @@ GhostDatatypeConstructors-Resolution.dfy(31,12): Error: field 'w' can be used on GhostDatatypeConstructors-Resolution.dfy(44,12): Error: field 'y' can be used only in specification contexts GhostDatatypeConstructors-Resolution.dfy(45,12): Error: field 'w' can be used only in specification contexts GhostDatatypeConstructors-Resolution.dfy(46,9): Error: ghost variables such as xy are allowed only in specification contexts. xy was inferred to be ghost based on its declaration or initialization. -GhostDatatypeConstructors-Resolution.dfy(101,17): Error: assignment to non-ghost variable is not allowed in this context, because the statement is in a ghost context; e.g., it may be guarded by a specification-only expression +GhostDatatypeConstructors-Resolution.dfy(101,20): Error: assignment to non-ghost variable is not allowed in this context, because the statement is in a ghost context; e.g., it may be guarded by a specification-only expression GhostDatatypeConstructors-Resolution.dfy(218,9): Error: type parameter (T) passed to function Eq must support equality (got XY) GhostDatatypeConstructors-Resolution.dfy(234,11): Error: ghost constructor is allowed only in specification contexts GhostDatatypeConstructors-Resolution.dfy(248,11): Error: ghost variables such as c are allowed only in specification contexts. c was inferred to be ghost based on its declaration or initialization. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/IteratorResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/IteratorResolution.dfy index 2ab2c0d61c8..e3277aee73b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/IteratorResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/IteratorResolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module SimplestIter { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy index 8b3300900aa..90053ae1932 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy @@ -308,8 +308,8 @@ function F_bad(d: Tuple< Tuple, Tuple< Tuple, Tuple >>): int { - var p, Pair(Pair(b0, x), Pair(Pair(y0, y1: nat), Pair(b1, b2))), q: int // error: int-to-nat failure - := d.0, d, d.1.0.1; + var p, Pair(Pair(b0, x), Pair(Pair(y0, y1: nat), Pair(b1, b2))), q: int + := d.0, d, d.1.0.1; // error: int-to-nat failure assert q < 200; // error: assertion failure p.1 + if b0 then x + y0 else x + y1 } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy.expect index af56c5c194e..f7d8bf1e292 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LetExpr.dfy.expect @@ -2,19 +2,19 @@ LetExpr.dfy(45,2): Warning: Could not find a trigger for this quantifier. Withou LetExpr.dfy(206,4): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. LetExpr.dfy(9,2): Error: assertion might not hold LetExpr.dfy(109,6): Error: assertion might not hold -LetExpr.dfy(260,18): Error: value does not satisfy the subset constraints of 'nat' +LetExpr.dfy(260,42): Error: value of expression (of type 'Tuple') is not known to be an instance of type 'Tuple' LetExpr.dfy(263,18): Error: value does not satisfy the subset constraints of 'nat' LetExpr.dfy(265,23): Error: value does not satisfy the subset constraints of 'nat' LetExpr.dfy(294,13): Error: RHS is not certain to look like the pattern 'Agnes' -LetExpr.dfy(311,41): Error: value does not satisfy the subset constraints of 'nat' +LetExpr.dfy(312,11): Error: value of expression (of type 'Tuple, Tuple, Tuple>>') is not known to be an instance of type 'Tuple, Tuple, Tuple>>' LetExpr.dfy(313,2): Error: assertion might not hold LetExpr.dfy(323,11): Error: to be compilable, the value of a let-such-that expression must be uniquely determined -LetExpr.dfy(340,18): Error: value does not satisfy the subset constraints of 'nat' -LetExpr.dfy(344,13): Error: value does not satisfy the subset constraints of 'nat' +LetExpr.dfy(340,34): Error: value of expression (of type 'Tuple') is not known to be an instance of type 'Tuple' +LetExpr.dfy(344,29): Error: value of expression (of type 'Tuple') is not known to be an instance of type 'Tuple' LetExpr.dfy(390,33): Error: assertion might not hold LetExpr.dfy(403,24): Error: assertion might not hold -Dafny program verifier finished with 37 verified, 13 errors +Dafny program verifier finished with 39 verified, 13 errors LetExpr.dfy.tmp.print.dfy(44,2): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. LetExpr.dfy.tmp.print.dfy(279,4): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LiberalEquality.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LiberalEquality.dfy index 1b010eaf231..76ee06d27d1 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LiberalEquality.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/LiberalEquality.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-deprecation --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" class Array diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MapMergeSubtraction.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MapMergeSubtraction.dfy index da033795d87..865248ed3a8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MapMergeSubtraction.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MapMergeSubtraction.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method Simple(m: map, n: map, s: set) returns (r: map) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MiscTypeInferenceTests.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MiscTypeInferenceTests.dfy index 1e2ca7fc231..9c8cca9ea52 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MiscTypeInferenceTests.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/MiscTypeInferenceTests.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %build "%s" --relax-definite-assignment --allow-axioms > "%t" +// RUN: %exits-with 4 %build --type-system-refresh=false --general-newtypes=false "%s" --relax-definite-assignment --allow-axioms > "%t" // RUN: %diff "%s.expect" "%t" // All of the examples in this file should type check (but some produce diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Modules0.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Modules0.dfy index a22ddbfbbb0..c42f9c362c5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Modules0.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/Modules0.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-axioms "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-axioms --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // ---------------------- duplicate types within a module diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy index a4b3f232479..ef72966008f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --relax-definite-assignment --allow-deprecation "%s" > "%t" +// RUN: %exits-with 4 %verify --relax-definite-assignment "%s" > "%t" // RUN: %diff "%s.expect" "%t" method M(n: nat) { @@ -11,11 +11,11 @@ method Main() { } class MyClass { - var f: nat; + var f: nat method CheckField(x: nat, y: int) - requires 0 <= y; - modifies this; + requires 0 <= y + modifies this { var y: nat := y; @@ -41,11 +41,11 @@ method Generic(i: int, t0: T, t1: T) returns (r: T) { var n: nat := 5; if case true => - var j := Generic(i-1, n, -4); // error: the type parameter is inferred as nat, but -4 is not a nat - assert 0 <= j; + var j := Generic(i-1, n, -4); // type parameter inferred to be "int", so "j" will be "int" + assert 0 <= j; // error: "j" has type "int" case true => - var j := Generic(i-1, n, 4); - assert 0 <= j; // fine, since type parameter was inferred as nat in previous call + var j := Generic(i-1, n, 4); // type parameter is inferred as "int" + assert 0 <= j; // error: "j" has type "int" case true => var j := Generic(i-1, n as int, -4); // now, the type parameter is inferred as int assert 0 <= j; // error: result may not be a nat @@ -61,8 +61,8 @@ method HenEric(i: int, t0: T, t1: T) returns (r: T) { var n: nat := 5; if case true => - var q := FenEric(n, -4); // error: type parameter is inferred as nat, but -4 is not a nat - assert 0 <= q; + var q := FenEric(n, -4); // type parameter inferred to be "int", so "j" will be "int" + assert 0 <= q; // error: "j" has type "int" case true => var q := FenEric(n, 4); assert 0 <= q; // fine, since type parameter was inferred as nat in previous call @@ -122,8 +122,8 @@ function GE(d: GenEric?): bool { true } method TestGenEric() { var ge; if (ge != null) { - var b := GE(ge); - var n: nat := ge.f; // the generic instantiation is inferred to be nat, so this is okay + var b := GE(ge); // type parameter inferred as "int" + var n: nat := ge.f; // error: ge.f has type "int" } } @@ -155,20 +155,20 @@ ghost function TakesANat(n: nat): bool } ghost function Naturally(): nat - ensures TakesANat(Naturally()); // the wellformedness of this check requires + ensures TakesANat(Naturally()) // the wellformedness of this check requires { 17 } ghost function Integrally_Bad(): int - ensures TakesANat(Integrally_Bad()); // error: well-formedness check fails + ensures TakesANat(Integrally_Bad()) // error: well-formedness check fails { 17 } ghost function Integrally_Good(): int - ensures 0 <= Integrally_Good(); - ensures TakesANat(Integrally_Good()); // here, the needed information follows from the preceding ensures clause + ensures 0 <= Integrally_Good() + ensures TakesANat(Integrally_Good()) // here, the needed information follows from the preceding ensures clause { 17 } @@ -178,9 +178,15 @@ ghost function Integrally_Good(): int datatype GList = GNil | GCons(G, GList) method GList_Append(xs: GList, x: int) returns (ys: GList) { - if 100 <= x { - ys := GCons(x, xs); // fine, result is a GList and x is a nat + if x < 100 { + ys := GCons(x as nat, xs); // error: result is a GList, but x may not be a nat + } else if 200 <= x { + ys := GCons(x as nat, xs); // fine, result is a GList and x is a nat + } else if 200 <= x { + ys := GList.GCons(x as nat, xs); // fine, result is a GList and x is a nat + } else if 300 <= x { + ys := GList.GCons(x, xs); // fine, result is a GList and x is provably a nat } else { - ys := GCons(x, xs); // error: result is a GList, but x may not be a nat + ys := GCons(x, xs); // error: RHS is inferred as GList and xs is not GList } } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy.expect index 4dfd23d81ac..b30bbbf8577 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NatTypes.dfy.expect @@ -1,15 +1,18 @@ NatTypes.dfy(10,4): Error: value does not satisfy the subset constraints of 'nat' NatTypes.dfy(35,11): Error: value does not satisfy the subset constraints of 'nat' -NatTypes.dfy(44,31): Error: value does not satisfy the subset constraints of 'nat' +NatTypes.dfy(45,6): Error: assertion might not hold +NatTypes.dfy(48,6): Error: assertion might not hold NatTypes.dfy(51,6): Error: assertion might not hold NatTypes.dfy(54,6): Error: assertion might not hold -NatTypes.dfy(64,26): Error: value does not satisfy the subset constraints of 'nat' +NatTypes.dfy(65,6): Error: assertion might not hold NatTypes.dfy(71,6): Error: assertion might not hold NatTypes.dfy(74,6): Error: assertion might not hold NatTypes.dfy(91,6): Error: assertion might not hold NatTypes.dfy(105,6): Error: assertion might not hold +NatTypes.dfy(126,21): Error: value does not satisfy the subset constraints of 'nat' NatTypes.dfy(141,44): Error: value does not satisfy the subset constraints of 'nat' NatTypes.dfy(164,34): Error: value does not satisfy the subset constraints of 'nat' -NatTypes.dfy(184,16): Error: value does not satisfy the subset constraints of 'nat' +NatTypes.dfy(182,18): Error: result of operation might violate subset type constraint for 'nat' +NatTypes.dfy(190,19): Error: value of expression (of type 'GList') is not known to be an instance of type 'GList' -Dafny program verifier finished with 7 verified, 13 errors +Dafny program verifier finished with 6 verified, 16 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NewtypesResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NewtypesResolution.dfy index 50b31b62c90..7ed0fe0e7cd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NewtypesResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NewtypesResolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-deprecation --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Cycle { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NonZeroInitializationCompile.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NonZeroInitializationCompile.dfy index 8e0d1dcd3ae..4a533178880 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NonZeroInitializationCompile.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/NonZeroInitializationCompile.dfy @@ -16,7 +16,7 @@ type WithTypeParameters = ignoreTypeParams: (int, bool) | true datatype Dt = Atom(short') | More(Dt) -trait Tr { +trait Tr extends object { var u: MyNewInt } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OlderVerification.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OlderVerification.dfy index 748313518e7..1b14bd6ebeb 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OlderVerification.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OlderVerification.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // ---------------------------------- diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OnDemandResolutionCycle.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OnDemandResolutionCycle.dfy.expect index a2dfc65e669..3781d9c1113 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OnDemandResolutionCycle.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/OnDemandResolutionCycle.dfy.expect @@ -1,15 +1,13 @@ OnDemandResolutionCycle.dfy(5,6): Error: Cyclic dependency among declarations: a -> A -> a -OnDemandResolutionCycle.dfy(4,15): Error: arguments must have comparable types (got ?1 and ?0) OnDemandResolutionCycle.dfy(9,9): Error: Cyclic dependency among declarations: FB -> B -> FB -> b OnDemandResolutionCycle.dfy(7,5): Error: Cyclic dependency among declarations: B -> B -> FB -> b OnDemandResolutionCycle.dfy(11,6): Error: Cyclic dependency among declarations: c0 -> c1 -> c0 OnDemandResolutionCycle.dfy(15,6): Error: Cyclic dependency among declarations: d -> D -> d OnDemandResolutionCycle.dfy(14,8): Error: base type of newtype 'D' is not fully determined; add an explicit type for bound variable 'x' -OnDemandResolutionCycle.dfy(14,18): Error: arguments must have comparable types (got ?1 and ?0) OnDemandResolutionCycle.dfy(19,9): Error: Cyclic dependency among declarations: FE -> E -> FE -> e OnDemandResolutionCycle.dfy(17,8): Error: Cyclic dependency among declarations: E -> E -> FE -> e OnDemandResolutionCycle.dfy(22,9): Error: Cyclic dependency among declarations: f -> F -> f OnDemandResolutionCycle.dfy(21,8): Error: Cyclic dependency among declarations: F -> F -> f OnDemandResolutionCycle.dfy(24,6): Error: Cyclic dependency among declarations: g -> g OnDemandResolutionCycle.dfy(15,14): Error: integer literal used as if it had type D -14 resolution/type errors detected in OnDemandResolutionCycle.dfy +12 resolution/type errors detected in OnDemandResolutionCycle.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/QuantificationNewSyntaxResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/QuantificationNewSyntaxResolution.dfy index bad392cf9fa..f6c549f78bd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/QuantificationNewSyntaxResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/QuantificationNewSyntaxResolution.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module {:options "/quantifierSyntax:4"} NewSyntax { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors1.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors1.dfy.refresh.expect index 14a17a6e76d..7cfce3b267c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors1.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors1.dfy.refresh.expect @@ -4,7 +4,9 @@ ResolutionErrors1.dfy(39,23): Error: type of case bodies do not agree (found Tre ResolutionErrors1.dfy(39,23): Error: type of case bodies do not agree (found Tree<_T1, _T0>, previous types Tree<_T0, _T1>) (covariant type parameter 'B' would require _T1 :> _T0) ResolutionErrors1.dfy(51,30): Error: Wrong number of type arguments (0 instead of 2) passed to datatype: Tree ResolutionErrors1.dfy(66,20): Error: unresolved identifier: w -ResolutionErrors1.dfy(86,33): Error: arguments must have comparable types (got ?8 and ?7) +ResolutionErrors1.dfy(85,8): Error: the type of this local variable is underspecified +ResolutionErrors1.dfy(86,24): Error: type parameter 'T' (inferred to be '?7') in the function call to 'P' could not be determined +ResolutionErrors1.dfy(86,18): Error: type of bound variable 'z' could not be determined; please specify the type explicitly ResolutionErrors1.dfy(99,13): Error: a lemma is not allowed to use 'new' ResolutionErrors1.dfy(100,9): Error: a lemma is not allowed to use 'new' ResolutionErrors1.dfy(109,16): Error: only ghost methods can be called from this context @@ -16,4 +18,4 @@ ResolutionErrors1.dfy(148,11): Error: assignment to array element is not allowed ResolutionErrors1.dfy(164,26): Error: second argument to 'in' must be a set, a multiset, a sequence with elements of type ?43, or a map with domain ?43 (instead got bool) ResolutionErrors1.dfy(171,21): Error: the type of this variable is underspecified ResolutionErrors1.dfy(183,13): Error: lemmas are not allowed to have modifies clauses -18 resolution/type errors detected in ResolutionErrors1.dfy +20 resolution/type errors detected in ResolutionErrors1.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors2.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors2.dfy.refresh.expect index a4397ec7c5e..ecde19d78f8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors2.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors2.dfy.refresh.expect @@ -37,7 +37,6 @@ ResolutionErrors2.dfy(283,34): Error: RHS (of type (int, int, real)) not assigna ResolutionErrors2.dfy(291,18): Error: member '3' does not exist in datatype '_tuple#3' ResolutionErrors2.dfy(291,28): Error: member 'x' does not exist in datatype '_tuple#2' ResolutionErrors2.dfy(290,18): Error: condition is expected to be of type bool, but is int -ResolutionErrors2.dfy(291,20): Error: arguments must have comparable types (got ?23 and ?24) ResolutionErrors2.dfy(314,21): Error: integer literal used as if it had type real ResolutionErrors2.dfy(315,9): Error: integer literal used as if it had type real ResolutionErrors2.dfy(315,12): Error: type of % must be integer-numeric or bitvector types (got real) @@ -78,4 +77,4 @@ ResolutionErrors2.dfy(489,27): Error: set comprehensions in non-ghost contexts m ResolutionErrors2.dfy(497,15): Error: arguments to / must be numeric or bitvector types (got set) ResolutionErrors2.dfy(504,20): Error: a call to a possibly non-terminating method is allowed only if the calling method is also declared (with 'decreases *') to be possibly non-terminating ResolutionErrors2.dfy(519,16): Error: a possibly infinite loop is allowed only if the enclosing method is declared (with 'decreases *') to be possibly non-terminating -78 resolution/type errors detected in ResolutionErrors2.dfy +77 resolution/type errors detected in ResolutionErrors2.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy index beda4a9fcf9..212ba94a51d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy @@ -204,8 +204,8 @@ module NonTypeVariableNames { method M(m: map) { - assert X == X; // error (x2): type name used as variable - assert Y == Y; // error (x2): module name used as variable + assert X == X; // error: type name used as variable + assert Y == Y; // error: module name used as variable assert X in m; // error (x2): type name used as variable assert Y in m; // error (x2): module name used as variable } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy.refresh.expect index 353a3e7b0f5..881ebc278f2 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors3.dfy.refresh.expect @@ -1,7 +1,6 @@ ResolutionErrors3.dfy(53,14): Error: type parameter 'PT' (inferred to be '?40') in the function call to 'P' could not be determined ResolutionErrors3.dfy(54,14): Error: the type of this variable is underspecified ResolutionErrors3.dfy(54,20): Error: type parameter 'QT' (inferred to be '?42') in the function call to 'Q' could not be determined -ResolutionErrors3.dfy(54,20): Error: the type of this expression is underspecified ResolutionErrors3.dfy(55,4): Error: type parameter 'MT' (inferred to be '?44') to the method 'M' could not be determined ResolutionErrors3.dfy(56,8): Error: the type of this variable is underspecified ResolutionErrors3.dfy(56,13): Error: type parameter 'NT' (inferred to be '?45') to the method 'N' could not be determined @@ -27,8 +26,6 @@ ResolutionErrors3.dfy(208,11): Error: name of module (Y) is used as a variable ResolutionErrors3.dfy(208,16): Error: name of module (Y) is used as a variable ResolutionErrors3.dfy(209,11): Error: name of type (X) is used as a variable ResolutionErrors3.dfy(210,11): Error: name of module (Y) is used as a variable -ResolutionErrors3.dfy(207,13): Error: arguments must have comparable types (got ?0 and ?1) -ResolutionErrors3.dfy(208,13): Error: arguments must have comparable types (got ?3 and ?4) ResolutionErrors3.dfy(215,16): Error: name of type (X) is used as a variable ResolutionErrors3.dfy(216,16): Error: name of module (Y) is used as a variable ResolutionErrors3.dfy(217,4): Error: name of type (X) is used as a variable @@ -83,8 +80,10 @@ ResolutionErrors3.dfy(535,27): Error: type of bound variable 'u' could not be de ResolutionErrors3.dfy(539,40): Error: type of bound variable 'u' could not be determined; please specify the type explicitly ResolutionErrors3.dfy(541,38): Error: type of bound variable 'u' could not be determined; please specify the type explicitly ResolutionErrors3.dfy(541,38): Error: type of bound variable 'u' could not be determined; please specify the type explicitly -ResolutionErrors3.dfy(555,40): Error: arguments must have comparable types (got set and set) -ResolutionErrors3.dfy(556,45): Error: arguments must have comparable types (got set and set) +ResolutionErrors3.dfy(555,26): Error: the type ('set') of this variable is underspecified +ResolutionErrors3.dfy(555,21): Error: type of bound variable 's' could not be determined ('set'); please specify the type explicitly +ResolutionErrors3.dfy(556,31): Error: the type ('set') of this variable is underspecified +ResolutionErrors3.dfy(556,21): Error: type of bound variable 's' could not be determined ('set'); please specify the type explicitly ResolutionErrors3.dfy(567,30): Error: the type ('C?') of this variable is underspecified ResolutionErrors3.dfy(567,21): Error: type of bound variable 'c' could not be determined ('C?'); please specify the type explicitly -89 resolution/type errors detected in ResolutionErrors3.dfy +88 resolution/type errors detected in ResolutionErrors3.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors4.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors4.dfy index 0bad62d5e36..ea20af15ea5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors4.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors4.dfy @@ -29,7 +29,7 @@ module AdvancedIndexableInference { // -------------------------- module TypeConversions { - trait J { } + trait J extends object { } class C extends J { } method M() returns (x: int, n: nat, o: object, j: J, c: C) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors5.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors5.dfy index 759ea2d29d4..b40fd4a8a00 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors5.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors5.dfy @@ -227,14 +227,14 @@ module UninterpretedModuleLevelConst { class ClassyTrait extends Trait { // fine, since the bad fields in Trait are static } - trait InstanceConst { + trait InstanceConst extends object { const w: MyClass } class Instance extends InstanceConst { // error: because of "w", must declare a constructor } - trait GhostTr { + trait GhostTr extends object { ghost const w: MyClass // the responsibility to initialize "w" lies with any class that implements "GhostTr" } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors9.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors9.dfy.refresh.expect index 9e3286dc385..ac4c26b1bf2 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors9.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/ResolutionErrors9.dfy.refresh.expect @@ -38,14 +38,14 @@ ResolutionErrors9.dfy(105,8): Error: when allocating an object of type 'Luci', o ResolutionErrors9.dfy(129,46): Error: boolean literal used as if it had type int ResolutionErrors9.dfy(210,16): Error: array selection requires integer- or bitvector-based numeric indices (got bool for index 0) ResolutionErrors9.dfy(210,23): Error: array selection requires integer- or bitvector-based numeric indices (got real for index 1) -ResolutionErrors9.dfy(212,17): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(212,22): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(213,17): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(214,19): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(215,15): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(215,20): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(216,15): Error: multi-element selection position expression must have an integer or bitvector type (got real) -ResolutionErrors9.dfy(217,17): Error: multi-element selection position expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(212,17): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(212,22): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(213,17): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(214,19): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(215,15): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(215,20): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(216,15): Error: multi-element selection expression must have an integer or bitvector type (got real) +ResolutionErrors9.dfy(217,17): Error: multi-element selection expression must have an integer or bitvector type (got real) ResolutionErrors9.dfy(208,13): Error: index expression must have an integer or bitvector type (got real) ResolutionErrors9.dfy(209,11): Error: index expression must have an integer or bitvector type (got real) 50 resolution/type errors detected in ResolutionErrors9.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/RuntimeTypeTests0.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/RuntimeTypeTests0.dfy index dec3d0e25dc..ff496eecaf3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/RuntimeTypeTests0.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/RuntimeTypeTests0.dfy @@ -23,7 +23,7 @@ method G() print s, " and ", t, "\n"; } -trait Tr { var u: char } +trait Tr extends object { var u: char } class Class0 extends Tr { var x: int } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy index 87eaf8cf0e8..554e4f34351 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy @@ -52,9 +52,9 @@ module Module1 { datatype Kt = Kt0(x: int) | - Kt1(ghost x: int) | // (duplicated destructors must agree on ghost/non-ghost, but this is not report until a later pass; see Module2) + Kt1(ghost x: int) | // error: duplicated destructors must agree on ghost/non-ghost Kt2(ghost g: int) | - Kt3(g: int) | // (duplicated destructors must agree on ghost/non-ghost, but this is not report until a later pass; see Module2) + Kt3(g: int) | // error: duplicated destructors must agree on ghost/non-ghost Kt4(k: Kt) | Kt5(k: SKt) | // fine, because SKt and Kt are synonyms Kt6(k: S'Kt) // fine, because S'Kt and Kt are synonyms diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy.expect index 78df34f29fd..f64506ceb8e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SharedDestructorsResolution.dfy.expect @@ -13,6 +13,8 @@ SharedDestructorsResolution.dfy(46,31): Error: updated datatype members must bel SharedDestructorsResolution.dfy(97,6): Error: Duplicate use of deconstructor name in the same constructor: x SharedDestructorsResolution.dfy(98,6): Error: Duplicate use of deconstructor name in the same constructor: y SharedDestructorsResolution.dfy(99,6): Error: Duplicate use of deconstructor name in the same constructor: z +SharedDestructorsResolution.dfy(55,14): Error: shared destructors must agree on whether or not they are ghost, but 'x' is non-ghost in constructor 'Kt0' and ghost in constructor 'Kt1' +SharedDestructorsResolution.dfy(57,8): Error: shared destructors must agree on whether or not they are ghost, but 'g' is ghost in constructor 'Kt2' and non-ghost in constructor 'Kt3' SharedDestructorsResolution.dfy(64,8): Error: shared destructors must have the same type, but 'x' has type 'int' in constructor 'Lt0' and type 'real' in constructor 'Lt1' SharedDestructorsResolution.dfy(69,8): Error: shared destructors must have the same type, but 'y' has type 'A' in constructor 'Mt0' and type 'B' in constructor 'Mt2' SharedDestructorsResolution.dfy(71,8): Error: shared destructors must have the same type, but 'arr' has type 'array' in constructor 'Mt3' and type 'array' in constructor 'Mt4' @@ -22,4 +24,4 @@ SharedDestructorsResolution.dfy(78,9): Error: shared destructors must have the s SharedDestructorsResolution.dfy(94,26): Error: shared destructors must have the same type, but 'u' has type 'int' in constructor 'Co2' and type 'real' in constructor 'Co3' SharedDestructorsResolution.dfy(105,14): Error: shared destructors must agree on whether or not they are ghost, but 'x' is non-ghost in constructor 'Kt0' and ghost in constructor 'Kt1' SharedDestructorsResolution.dfy(107,8): Error: shared destructors must agree on whether or not they are ghost, but 'g' is ghost in constructor 'Kt2' and non-ghost in constructor 'Kt3' -24 resolution/type errors detected in SharedDestructorsResolution.dfy +26 resolution/type errors detected in SharedDestructorsResolution.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypes.dfy index 19773e1c00a..62d8d521c13 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypes.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" --performance-stats=100 --relax-definite-assignment --allow-axioms > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" --performance-stats=100 --relax-definite-assignment --allow-axioms > "%t" // RUN: %diff "%s.expect" "%t" module AssignmentToNat { @@ -46,9 +46,9 @@ module AssignmentToNat { method Q(x: int) { var f := Pf; var g := Pg; - var a := f(x); // error + var a := f(x); // error: x may be negative var id := (u: int) => u; - g := id; // error + g := id; } ghost function Id(x: int): nat diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy index cb500b51206..61c9785778f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 4 %verify --relax-definite-assignment "%s" > "%t" // RUN: %diff "%s.expect" "%t" module AssignmentsFromNewAllocation { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy.expect index 018a2024989..78ef84cd661 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/SubsetTypesERR.dfy.expect @@ -1,18 +1,19 @@ -SubsetTypesERR.dfy(11,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(13,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(15,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(17,8): Error: RHS (of type array) not assignable to LHS (of type array) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(23,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(25,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(27,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(29,8): Error: RHS (of type array) not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(37,8): Error: RHS (of type array) not assignable to LHS (of type array) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(39,8): Error: RHS (of type array) not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(42,8): Error: RHS (of type array) not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(44,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(46,8): Error: type array is not assignable to LHS (of type array) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(57,8): Error: type Cell is not assignable to LHS (of type Cell) (nonvariance for type parameter expects Person = Person?) -SubsetTypesERR.dfy(59,8): Error: type Cell is not assignable to LHS (of type Cell) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(63,8): Error: RHS (of type Cell) not assignable to LHS (of type Cell) (nonvariance for type parameter expects Person? = Person) -SubsetTypesERR.dfy(65,8): Error: RHS (of type Cell) not assignable to LHS (of type Cell) (nonvariance for type parameter expects Person = Person?) -17 resolution/type errors detected in SubsetTypesERR.dfy +SubsetTypesERR.dfy(11,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(13,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(15,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(17,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(23,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(25,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(27,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(29,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(37,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(39,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(42,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(44,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(46,11): Error: value of expression (of type 'array') is not known to be an instance of type 'array' +SubsetTypesERR.dfy(57,11): Error: value of expression (of type 'Cell') is not known to be an instance of type 'Cell' +SubsetTypesERR.dfy(59,11): Error: value of expression (of type 'Cell') is not known to be an instance of type 'Cell' +SubsetTypesERR.dfy(63,11): Error: value of expression (of type 'Cell') is not known to be an instance of type 'Cell' +SubsetTypesERR.dfy(65,11): Error: value of expression (of type 'Cell') is not known to be an instance of type 'Cell' + +Dafny program verifier finished with 0 verified, 17 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy index db6404ba63b..6211cf00113 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build --rprint:- "%s" > "%t" +// RUN: %exits-with 2 %build --rprint:- --type-system-refresh=false --general-traits=legacy --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Tests { class CC { @@ -152,9 +152,9 @@ module MorePlusTests { module References { class C extends K, M { } - trait R { } - trait K { } - trait M { } + trait R extends object { } + trait K extends object { } + trait M extends object { } method M0() returns (c: C, r: R) { @@ -178,12 +178,12 @@ module References { method M2() returns (c: C, r: R, o: object) { - c := o; // OK for type resolution, but must be proved + c := o as C; // OK for type resolution, but must be proved } method M3() returns (c: C, r: R, o: object) { - r := o; // OK for type resolution, but must be proved + r := o as R; // OK for type resolution, but must be proved } } @@ -191,7 +191,7 @@ module SimpleClassesAndTraits { class C extends K, M { } class D extends K, M { } trait R { } - trait K { var h: int } + trait K extends object { var h: int } trait M { } method Infer(c: C, o: object, k: K, d: D) returns (k': K) { @@ -285,7 +285,7 @@ module Datatypes { } module TraitStuff { - trait Part { + trait Part extends object { var id: int } trait Motorized { } @@ -467,7 +467,7 @@ module Arrays_and_SubsetTypesOK { } module TypeArgumentPrintTests { - trait Tr { } + trait Tr extends object { } class Cl extends Tr { lemma M() { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy.expect index 040e618a2cd..c27aa943096 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraints.dfy.expect @@ -399,12 +399,12 @@ module References { method M2() returns (c: C, r: R, o: object) { - c := o; + c := o as C; } method M3() returns (c: C, r: R, o: object) { - r := o; + r := o as R; } class C extends K, M { } @@ -412,17 +412,17 @@ module References { type {:axiom} C(==) = c: C? | c != null /*special witness*/ */ - trait R { } + trait R extends object { } /*-- non-null type type {:axiom} R(==) = c: R? | c != null /*special witness*/ */ - trait K { } + trait K extends object { } /*-- non-null type type {:axiom} K(==) = c: K? | c != null /*special witness*/ */ - trait M { } + trait M extends object { } /*-- non-null type type {:axiom} M(==) = c: M? | c != null /*special witness*/ */ @@ -484,7 +484,7 @@ module SimpleClassesAndTraits { type {:axiom} R(==) = c: R? | c != null /*special witness*/ */ - trait K { + trait K extends object { var h: int } /*-- non-null type @@ -587,7 +587,7 @@ module TraitStuff { * SCC at height 0: * PartZ */ - trait Part { + trait Part extends object { var id: int } /*-- non-null type @@ -627,7 +627,7 @@ module TraitStuff { z := new PartZ; Repr := {this, x, y, z}; new; - var parts: set := {x, y}; + var parts: set := {x, y}; var ooo: set := {y, z}; } } @@ -853,7 +853,7 @@ module TypeArgumentPrintTests { * SCC at height 0: * Tr */ - trait Tr { } + trait Tr extends object { } /*-- non-null type type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ */ diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy index 109e8f58f66..2338ff1499a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy @@ -152,9 +152,9 @@ module MorePlusTests { module References { class C extends K, M { } - trait R { } - trait K { } - trait M { } + trait R extends object { } + trait K extends object { } + trait M extends object { } method M0() returns (c: C, r: R) { @@ -191,7 +191,7 @@ module SimpleClassesAndTraits { class C extends K, M { } class D extends K, M { } trait R { } - trait K { var h: int } + trait K extends object { var h: int } trait M { } method Infer(c: C, o: object, k: K, d: D) returns (k': K) { @@ -285,7 +285,7 @@ module Datatypes { } module TraitStuff { - trait Part { + trait Part extends object { var id: int } trait Motorized { } @@ -321,8 +321,8 @@ module OtherTraitsAndClasses { y := m + m; } - trait J { } - trait K { } + trait J extends object { } + trait K extends object { } class C extends J { } class D extends J, K { } class E { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy.expect index 475a725c910..aa9d2fc3a0c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConstraintsRefresh.dfy.expect @@ -6,7 +6,7 @@ TypeConstraintsRefresh.dfy(80,6): Error: RHS (of type MyInt) not assignable to L TypeConstraintsRefresh.dfy(81,6): Error: RHS (of type int) not assignable to LHS (of type MyInt) TypeConstraintsRefresh.dfy(78,6): Error: RHS (of type MyInt) not assignable to LHS (of type int) TypeConstraintsRefresh.dfy(79,6): Error: RHS (of type int) not assignable to LHS (of type MyInt) -TypeConstraintsRefresh.dfy(95,11): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got ?3) +TypeConstraintsRefresh.dfy(95,11): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got ?2) TypeConstraintsRefresh.dfy(102,11): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got bool) TypeConstraintsRefresh.dfy(136,16): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got bool) TypeConstraintsRefresh.dfy(147,16): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got C?) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversions.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversions.dfy index bc58dbfbd4d..0154d76920e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversions.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversions.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachResolver --expect-exit-code=4 "%s" -- --relax-definite-assignment --rprint:- +// RUN: %testDafnyForEachResolver --expect-exit-code=4 "%s" -- --relax-definite-assignment --general-newtypes=false --rprint:- newtype EvenInt = x | x % 2 == 0 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversionsCompile.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversionsCompile.dfy index 2bac358510f..bf174a9e46a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversionsCompile.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeConversionsCompile.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment --general-newtypes=false // Note the difference in output in Java's case is due to // https://github.com/dafny-lang/dafny/issues/4152 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy index fb785503221..e4c886b8d4c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy @@ -1031,6 +1031,28 @@ module TypeInferenceViaInAndEquals { method MagicAssign() returns (r: X) } +module CollectionUpdates { + method P(n: nat) returns (m: map, j: multiset) { + m := map[n := n]; + j := multiset{n, n, n}; + + m := m[n := 10]; + m := m[10 := n]; + m := m[n := n]; + j := j[n := 38]; + } + + trait Trait extends object { } + + method Q(n: Trait) returns (m: map, j: multiset) { + m := map[n := n]; + j := multiset{n, n, n}; + + m := m[n := n]; + j := j[n := 38]; + } +} + /**************************************************************************************** ******** TO DO ************************************************************************* **************************************************************************************** diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy.expect index a09670b9feb..5e9bdb3933f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefresh.dfy.expect @@ -11,4 +11,4 @@ TypeInferenceRefresh.dfy(633,18): Error: value does not satisfy the subset const TypeInferenceRefresh.dfy(633,21): Error: value does not satisfy the subset constraints of 'nat' TypeInferenceRefresh.dfy(633,24): Error: value does not satisfy the subset constraints of 'nat' -Dafny program verifier finished with 84 verified, 10 errors +Dafny program verifier finished with 86 verified, 10 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefreshErrors.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefreshErrors.dfy.expect index 98fc6b86e56..c53d181ac5b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefreshErrors.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInferenceRefreshErrors.dfy.expect @@ -8,10 +8,7 @@ TypeInferenceRefreshErrors.dfy(34,12): Error: type cast to reference type 'D' mu TypeInferenceRefreshErrors.dfy(49,8): Error: the type ('E?') of this variable is underspecified TypeInferenceRefreshErrors.dfy(50,16): Error: the type ('E') of this expression is underspecified TypeInferenceRefreshErrors.dfy(51,16): Error: the type ('E>') of this expression is underspecified -TypeInferenceRefreshErrors.dfy(64,8): Error: the type ('map') of this local variable is underspecified -TypeInferenceRefreshErrors.dfy(65,8): Error: the type ('map') of this local variable is underspecified -TypeInferenceRefreshErrors.dfy(66,8): Error: the type ('map') of this local variable is underspecified -TypeInferenceRefreshErrors.dfy(67,11): Error: the type ('map') of this expression is underspecified +TypeInferenceRefreshErrors.dfy(64,8): Error: the type ('map') of this local variable is underspecified TypeInferenceRefreshErrors.dfy(76,8): Error: the type ('Synonym') of this variable is underspecified TypeInferenceRefreshErrors.dfy(85,8): Error: the type ('SubsetType') of this variable is underspecified TypeInferenceRefreshErrors.dfy(97,8): Error: the type ('Synonym') of this variable is underspecified @@ -23,9 +20,9 @@ TypeInferenceRefreshErrors.dfy(112,13): Error: datatype constructor does not tak TypeInferenceRefreshErrors.dfy(122,9): Error: type '(int, int)' does not contain a datatype constructor 'R' TypeInferenceRefreshErrors.dfy(124,12): Error: unresolved identifier: x TypeInferenceRefreshErrors.dfy(124,16): Error: unresolved identifier: y -TypeInferenceRefreshErrors.dfy(124,14): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got ?7) +TypeInferenceRefreshErrors.dfy(124,14): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got ?6) TypeInferenceRefreshErrors.dfy(131,11): Error: literal (84848484848484848) is too large for the bitvector type bv7 -TypeInferenceRefreshErrors.dfy(140,11): Error: type of real literal is used as bv7 +TypeInferenceRefreshErrors.dfy(140,11): Error: real literal used as if it had type bv7 TypeInferenceRefreshErrors.dfy(143,11): Error: integer literal used as if it had type real TypeInferenceRefreshErrors.dfy(144,11): Error: integer literal used as if it had type real TypeInferenceRefreshErrors.dfy(145,11): Error: integer literal used as if it had type real @@ -47,4 +44,4 @@ TypeInferenceRefreshErrors.dfy(269,15): Error: arguments to >= must be of a nume TypeInferenceRefreshErrors.dfy(268,15): Error: arguments to > must be of a numeric type, bitvector type, ORDINAL, char, or a set-like type (instead got bool) TypeInferenceRefreshErrors.dfy(275,34): Error: array-allocation initialization expression expected to have type 'nat ~> bool' (instead got 'nat -> nat') (covariant type parameter 'R' would require bool :> nat) TypeInferenceRefreshErrors.dfy(279,35): Error: integer literal used as if it had type bool -46 resolution/type errors detected in TypeInferenceRefreshErrors.dfy +43 resolution/type errors detected in TypeInferenceRefreshErrors.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInstantiations.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInstantiations.dfy index 54aad21f2cc..5dc705b1a17 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInstantiations.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeInstantiations.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" abstract module M0 { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeTests.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeTests.dfy index 617b0325d70..bae68aae55f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeTests.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/TypeTests.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-deprecation --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Tests { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/UserSpecifiedTypeParameters.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/UserSpecifiedTypeParameters.dfy index 51f2e101cb1..01b00160c06 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/UserSpecifiedTypeParameters.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny0/UserSpecifiedTypeParameters.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module M0 { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny1/Rippling.legacy.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny1/Rippling.legacy.dfy index 8fffa7ceed4..9d94eba54ac 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny1/Rippling.legacy.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny1/Rippling.legacy.dfy @@ -357,7 +357,7 @@ lemma P11() } lemma P12() - ensures forall n, xs, f :: drop(n, apply(f, xs)) == apply(f, drop(n, xs)); + ensures forall n, xs, f: Nat -> Nat :: drop(n, apply(f, xs)) == apply(f, drop(n, xs)); { } @@ -367,7 +367,7 @@ lemma P13() } lemma P14() - ensures forall xs, ys, p :: filter(p, concat(xs, ys)) == concat(filter(p, xs), filter(p, ys)); + ensures forall xs, ys, p: Nat -> Nat :: filter(p, concat(xs, ys)) == concat(filter(p, xs), filter(p, ys)); { } @@ -505,7 +505,7 @@ lemma P40() } lemma P41() - ensures forall n, xs, f :: take(n, apply(f, xs)) == apply(f, take(n, xs)); + ensures forall n, xs, f: Nat -> Nat :: take(n, apply(f, xs)) == apply(f, take(n, xs)); { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny2/COST-verif-comp-2011-4-FloydCycleDetect.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny2/COST-verif-comp-2011-4-FloydCycleDetect.dfy index 8064a5c49b3..be1740b10d7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny2/COST-verif-comp-2011-4-FloydCycleDetect.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny2/COST-verif-comp-2011-4-FloydCycleDetect.dfy @@ -153,7 +153,7 @@ class Node { method Cyclic(ghost S: set) returns (reachesCycle: bool) requires IsClosed(S) - ensures reachesCycle <==> exists n :: Reaches(n, S) && n.next != null && n.next.Reaches(n, S) + ensures reachesCycle <==> exists n: Node :: Reaches(n, S) && n.next != null && n.next.Reaches(n, S) { ghost var A, B := AnalyzeList(S); var tortoise, hare:= this, next; diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Abstemious.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Abstemious.dfy index 258e7be2e6f..aa0a1cc1a31 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Abstemious.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Abstemious.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment --type-system-refresh=false --general-newtypes=false // Examples from https://www.haskell.org/tutorial/functions.html diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Filter.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Filter.dfy.expect index 8a923ac640e..94ea176b77c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Filter.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/Filter.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 28 verified, 0 errors +Dafny program verifier finished with 30 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/InfiniteTrees.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/InfiniteTrees.dfy index 015f77bbb39..e0eae54ebf3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/InfiniteTrees.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/InfiniteTrees.dfy @@ -1,4 +1,4 @@ -// RUN: %verify --allow-deprecation "%s" > "%t" +// RUN: %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // Here is the usual definition of possibly infinite lists, along with a function Tail(s, n), which drops @@ -14,13 +14,13 @@ ghost function Tail(s: Stream, n: nat): Stream } lemma Tail_Lemma0(s: Stream, n: nat) - requires s.Cons? && Tail(s, n).Cons?; - ensures Tail(s, n).tail == Tail(s.tail, n); + requires s.Cons? && Tail(s, n).Cons? + ensures Tail(s, n).tail == Tail(s.tail, n) { } lemma Tail_Lemma1(s: Stream, k: nat, n: nat) - requires k <= n; - ensures Tail(s, n).Cons? ==> Tail(s, k).Cons?; + requires k <= n + ensures Tail(s, n).Cons? ==> Tail(s, k).Cons? // Note, the contrapositive of this lemma says: Tail(s, k) == Nil ==> Tail(s, n) == Nil { if k < n && Tail(s, n).Cons? { @@ -28,8 +28,8 @@ lemma Tail_Lemma1(s: Stream, k: nat, n: nat) } } lemma Tail_Lemma2(s: Stream, n: nat) - requires s.Cons? && Tail(s.tail, n).Cons?; - ensures Tail(s, n).Cons?; + requires s.Cons? && Tail(s.tail, n).Cons? + ensures Tail(s, n).Cons? { if n != 0 { Tail_Lemma0(s, n-1); @@ -52,7 +52,7 @@ ghost function AnInfiniteStream(): Stream Cons(0, AnInfiniteStream()) } greatest lemma Proposition0() - ensures IsNeverEndingStream(AnInfiniteStream()); + ensures IsNeverEndingStream(AnInfiniteStream()) { } @@ -80,7 +80,7 @@ greatest predicate LowerThan(s: Stream, n: nat) // LowerThan(s, h) implies LowerThan(s', h) for any suffix s' of s. lemma LowerThan_Lemma(s: Stream, n: nat, h: nat) - ensures LowerThan(s, h) ==> LowerThan(Tail(s, n), h); + ensures LowerThan(s, h) ==> LowerThan(Tail(s, n), h) { Tail_Lemma1(s, 0, n); if n == 0 || Tail(s, n) == Nil { @@ -117,7 +117,7 @@ ghost function SkinnyTree(): Tree Node(Cons(SkinnyTree(), Nil)) } lemma Proposition1() - ensures IsFiniteSomewhere(SkinnyTree()) && !HasBoundedHeight(SkinnyTree()); + ensures IsFiniteSomewhere(SkinnyTree()) && !HasBoundedHeight(SkinnyTree()) { assert forall n {:induction} :: 0 <= n ==> !LowerThan(SkinnyTree().children, n); } @@ -125,8 +125,8 @@ lemma Proposition1() // Any tree where all paths have bounded height are finite somewhere. lemma Theorem0(t: Tree) - requires HasBoundedHeight(t); - ensures IsFiniteSomewhere(t); + requires HasBoundedHeight(t) + ensures IsFiniteSomewhere(t) { var n :| 0 <= n && LowerThan(t.children, n); /* @@ -137,8 +137,8 @@ lemma Theorem0(t: Tree) var k := FindNil(t.children, n); } lemma FindNil(s: Stream, n: nat) returns (k: nat) - requires LowerThan(s, n); - ensures !InfiniteEverywhere#[k as ORDINAL](s); + requires LowerThan(s, n) + ensures !InfiniteEverywhere#[k as ORDINAL](s) { match s { case Nil => k := 1; @@ -179,18 +179,18 @@ ghost function ATreeChildren(): Stream Cons(Node(Nil), ATreeChildren()) } lemma Proposition2() - ensures !HasFiniteHeightEverywhere_Bad(ATree()); + ensures !HasFiniteHeightEverywhere_Bad(ATree()) { Proposition2_Lemma0(); Proposition2_Lemma1(ATreeChildren()); } greatest lemma Proposition2_Lemma0() - ensures IsNeverEndingStream(ATreeChildren()); + ensures IsNeverEndingStream(ATreeChildren()) { } greatest lemma Proposition2_Lemma1(s: Stream) - requires IsNeverEndingStream(s); - ensures InfiniteHeightSomewhere_Bad(s); + requires IsNeverEndingStream(s) + ensures InfiniteHeightSomewhere_Bad(s) { calc { InfiniteHeightSomewhere_Bad#[_k](s); @@ -241,7 +241,7 @@ greatest predicate ValidPath(t: Tree, p: Stream) ch.Cons? && ValidPath(ch.head, tail) } lemma ValidPath_Lemma(p: Stream) - ensures ValidPath(Node(Nil), p) ==> p == Nil; + ensures ValidPath(Node(Nil), p) ==> p == Nil { if ValidPath(Node(Nil), p) { match p { @@ -263,8 +263,8 @@ ghost predicate HasFiniteHeight(t: Tree) // From this definition, we can prove that any tree of bounded height is also of finite height. lemma Theorem1(t: Tree) - requires HasBoundedHeight(t); - ensures HasFiniteHeight(t); + requires HasBoundedHeight(t) + ensures HasFiniteHeight(t) { var n :| 0 <= n && LowerThan(t.children, n); forall p | ValidPath(t, p) { @@ -272,9 +272,9 @@ lemma Theorem1(t: Tree) } } lemma Theorem1_Lemma(t: Tree, n: nat, p: Stream) - requires LowerThan(t.children, n) && ValidPath(t, p); - ensures !IsNeverEndingStream(p); - decreases n; + requires LowerThan(t.children, n) && ValidPath(t, p) + ensures !IsNeverEndingStream(p) + decreases n { match p { case Nil => @@ -298,7 +298,7 @@ lemma Theorem1_Lemma(t: Tree, n: nat, p: Stream) // Define SkinnyFiniteTree(n) to be a skinny (that is, of width 1) tree of height n. ghost function SkinnyFiniteTree(n: nat): Tree - ensures forall k: nat :: LowerThan(SkinnyFiniteTree(n).children, k) <==> n <= k; + ensures forall k: nat :: LowerThan(SkinnyFiniteTree(n).children, k) <==> n <= k { if n == 0 then Node(Nil) else Node(Cons(SkinnyFiniteTree(n-1), Nil)) } @@ -316,9 +316,9 @@ ghost function EverLongerSkinnyTrees(n: nat): Stream } lemma EverLongerSkinnyTrees_Lemma(k: nat, n: nat) - ensures Tail(EverLongerSkinnyTrees(k), n).Cons?; - ensures Tail(EverLongerSkinnyTrees(k), n).head == SkinnyFiniteTree(k+n); - decreases n; + ensures Tail(EverLongerSkinnyTrees(k), n).Cons? + ensures Tail(EverLongerSkinnyTrees(k), n).head == SkinnyFiniteTree(k+n) + decreases n { if n == 0 { } else { @@ -335,17 +335,17 @@ lemma EverLongerSkinnyTrees_Lemma(k: nat, n: nat) } lemma Proposition3() - ensures !HasBoundedHeight(FiniteUnboundedTree()) && HasFiniteHeight(FiniteUnboundedTree()); + ensures !HasBoundedHeight(FiniteUnboundedTree()) && HasFiniteHeight(FiniteUnboundedTree()) { Proposition3a(); Proposition3b(); } lemma Proposition3a() - ensures !HasBoundedHeight(FiniteUnboundedTree()); + ensures !HasBoundedHeight(FiniteUnboundedTree()) { var ch := FiniteUnboundedTree().children; forall n | 0 <= n - ensures !LowerThan(ch, n); + ensures !LowerThan(ch, n) { var cn := Tail(ch, n+1); EverLongerSkinnyTrees_Lemma(0, n+1); @@ -355,11 +355,11 @@ lemma Proposition3a() } } lemma Proposition3b() - ensures HasFiniteHeight(FiniteUnboundedTree()); + ensures HasFiniteHeight(FiniteUnboundedTree()) { var t := FiniteUnboundedTree(); forall p | ValidPath(t, p) - ensures !IsNeverEndingStream(p); + ensures !IsNeverEndingStream(p) { assert p.Cons?; var index := p.head; @@ -473,14 +473,14 @@ ghost predicate HasFiniteHeight_Alt(t: Tree) // Stream and CoOption, and then prove some lemmas about this correspondence. ghost function S2N(p: Stream): CoOption - decreases 0; + decreases 0 { match p case Nil => None case Cons(n, tail) => Some(S2N'(if n < 0 then 0 else n, tail)) } ghost function S2N'(n: nat, tail: Stream): Number - decreases n + 1; + decreases n + 1 { if n <= 0 then Zero(S2N(tail)) else Succ(S2N'(n-1, tail)) } @@ -492,7 +492,7 @@ ghost function N2S(r: CoOption): Stream case Some(num) => N2S'(0, num) } ghost function N2S'(n: nat, num: Number): Stream - decreases num; + decreases num { match num case Zero(r) => Cons(n, N2S(r)) @@ -500,16 +500,16 @@ ghost function N2S'(n: nat, num: Number): Stream } lemma Path_Lemma0(t: Tree, p: Stream) - requires ValidPath(t, p); - ensures ValidPath_Alt(t, S2N(p)); + requires ValidPath(t, p) + ensures ValidPath_Alt(t, S2N(p)) { if ValidPath(t, p) { Path_Lemma0'(t, p); } } greatest lemma Path_Lemma0'(t: Tree, p: Stream) - requires ValidPath(t, p); - ensures ValidPath_Alt(t, S2N(p)); + requires ValidPath(t, p) + ensures ValidPath_Alt(t, S2N(p)) { match p { case Nil => @@ -531,8 +531,8 @@ greatest lemma Path_Lemma0'(t: Tree, p: Stream) } } greatest lemma Path_Lemma0''(tChildren: Stream, n: nat, tail: Stream) - requires var ch := Tail(tChildren, n); ch.Cons? && ValidPath(ch.head, tail); - ensures ValidPath_Alt'(tChildren, S2N'(n, tail)); + requires var ch := Tail(tChildren, n); ch.Cons? && ValidPath(ch.head, tail) + ensures ValidPath_Alt'(tChildren, S2N'(n, tail)) { Tail_Lemma1(tChildren, 0, n); match S2N'(n, tail) { @@ -550,17 +550,17 @@ greatest lemma Path_Lemma0''(tChildren: Stream, n: nat, tail: Stream) } } lemma Path_Lemma1(t: Tree, r: CoOption) - requires ValidPath_Alt(t, r); - ensures ValidPath(t, N2S(r)); + requires ValidPath_Alt(t, r) + ensures ValidPath(t, N2S(r)) { if ValidPath_Alt(t, r) { Path_Lemma1'(t, r); } } greatest lemma Path_Lemma1'(t: Tree, r: CoOption) - requires ValidPath_Alt(t, r); - ensures ValidPath(t, N2S(r)); - decreases 1; + requires ValidPath_Alt(t, r) + ensures ValidPath(t, N2S(r)) + decreases 1 { match r { case None => @@ -581,9 +581,9 @@ greatest lemma Path_Lemma1'(t: Tree, r: CoOption) } } greatest lemma Path_Lemma1''(s: Stream, n: nat, num: Number) - requires ValidPath_Alt'(Tail(s, n), num); - ensures ValidPath(Node(s), N2S'(n, num)); - decreases 0, num; + requires ValidPath_Alt'(Tail(s, n), num) + ensures ValidPath(Node(s), N2S'(n, num)) + decreases 0, num { match num { case Succ(next) => @@ -601,15 +601,15 @@ greatest lemma Path_Lemma1''(s: Stream, n: nat, num: Number) } } lemma Path_Lemma2(p: Stream) - ensures IsNeverEndingStream(p) ==> InfinitePath(S2N(p)); + ensures IsNeverEndingStream(p) ==> InfinitePath(S2N(p)) { if IsNeverEndingStream(p) { Path_Lemma2'(p); } } greatest lemma Path_Lemma2'(p: Stream) - requires IsNeverEndingStream(p); - ensures InfinitePath(S2N(p)); + requires IsNeverEndingStream(p) + ensures InfinitePath(S2N(p)) { match p { case Cons(n, tail) => @@ -633,7 +633,7 @@ greatest lemma Path_Lemma2''(p: Stream, n: nat, tail: Stream) Path_Lemma2'(tail); } lemma Path_Lemma3(r: CoOption) - ensures InfinitePath(r) ==> IsNeverEndingStream(N2S(r)); + ensures InfinitePath(r) ==> IsNeverEndingStream(N2S(r)) { if InfinitePath(r) { match r { @@ -642,9 +642,9 @@ lemma Path_Lemma3(r: CoOption) } } greatest lemma Path_Lemma3'(n: nat, num: Number) - requires InfinitePath'(num); - ensures IsNeverEndingStream(N2S'(n, num)); - decreases num; + requires InfinitePath'(num) + ensures IsNeverEndingStream(N2S'(n, num)) + decreases num { match num { case Zero(r) => @@ -663,7 +663,7 @@ greatest lemma Path_Lemma3'(n: nat, num: Number) } lemma Theorem2(t: Tree) - ensures HasFiniteHeight(t) <==> HasFiniteHeight_Alt(t); + ensures HasFiniteHeight(t) <==> HasFiniteHeight_Alt(t) { if HasFiniteHeight_Alt(t) { forall p { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy index 54e444ea2b6..1032a2ae855 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy @@ -1,4 +1,4 @@ -// RUN: %verify --allow-deprecation "%s" > "%t" +// RUN: %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" codatatype Stream = SNil | SCons(head: T, tail: Stream) @@ -10,7 +10,7 @@ ghost function BigTree(): Tree Node(BigTrees()) } ghost function BigTrees(): Stream - decreases 0; + decreases 0 { SCons(BigTree(), BigTrees()) } @@ -34,18 +34,18 @@ ghost function SmallTree(n: nat): Tree Node(SmallTrees(n)) } ghost function SmallTrees(n: nat): Stream - decreases -1; + decreases -1 { if n == 0 then SNil else SCons(SmallTree(n-1), SmallTrees(n)) } // prove that the tree returned by SmallTree is finite lemma Theorem(n: nat) - ensures HasBoundedHeight(SmallTree(n)); + ensures HasBoundedHeight(SmallTree(n)) { Lemma(n); } greatest lemma Lemma(n: nat) - ensures LowerThan(SmallTrees(n), n); + ensures LowerThan(SmallTrees(n), n) { if 0 < n { Lemma(n-1); diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy.expect index 83193971bf0..851aaf58286 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny3/WideTrees.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 6 verified, 0 errors +Dafny program verifier finished with 7 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy index aab084a9455..4c73c27abc5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy @@ -6,8 +6,10 @@ method M() { var s := [1, "2"]; // error: all elements must have the same type (type of s not yet determined) if * { - assert "2" in s; // This causes the type of s to be inferred as seq. - } else if * { // Thus, the n in the next line is inferred as string (or seq) - assert exists n :: n in s && n != 1; // error: mismatched types + assert "2" in s; // error: mismatched types (*) + } else if * { + assert exists n :: n in s && n != 1; // error: mismatched types (*) } + + // (*) Depending on what type is inferred for "s", it may be that only one of the two (*)'s is reported as an error. } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy.expect index e561b30a5c3..5423f2687bf 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression0.dfy.expect @@ -1,3 +1,3 @@ -Regression0.dfy(7,12): Error: All elements of display must have some common supertype (got int, but needed type or type of previous elements is seq) -Regression0.dfy(11,25): Error: second argument to "in" must be a set, multiset, or sequence with elements of type int, or a map with domain int (instead got seq>) (expecting element type to be assignable to seq (got int)) +Regression0.dfy(7,15): Error: All elements of display must have some common supertype (got string, but needed type or type of previous elements is int) +Regression0.dfy(9,15): Error: expecting element type to be assignable to int (got string) 2 resolution/type errors detected in Regression0.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression11.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression11.dfy.expect index 084079b0210..f83961ab2e7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression11.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression11.dfy.expect @@ -1,12 +1,12 @@ Regression11.dfy(14,38): Error: Type or type parameter is not declared in this scope: B (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) Regression11.dfy(16,36): Error: Type or type parameter is not declared in this scope: C (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) Regression11.dfy(18,39): Error: Type or type parameter is not declared in this scope: D (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) -Regression11.dfy(18,45): Error: type of 'null' is a reference type, but it is used as MyClass +Regression11.dfy(18,45): Error: type of 'null' is a reference type, but it is used as () Regression11.dfy(20,31): Error: Type or type parameter is not declared in this scope: MaiKlass (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) -Regression11.dfy(20,51): Error: type of 'null' is a reference type, but it is used as MaiKlass +Regression11.dfy(20,51): Error: type of 'null' is a reference type, but it is used as () Regression11.dfy(25,37): Error: Type or type parameter is not declared in this scope: B (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) Regression11.dfy(27,36): Error: Type or type parameter is not declared in this scope: C (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) Regression11.dfy(29,44): Error: Type or type parameter is not declared in this scope: D (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) Regression11.dfy(29,32): Error: Wrong number of type arguments (2 instead of 1) passed to non-null type: MyClass -Regression11.dfy(29,50): Error: type of 'null' is a reference type, but it is used as MyClass +Regression11.dfy(29,50): Error: type of 'null' is a reference type, but it is used as () 11 resolution/type errors detected in Regression11.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression12.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression12.dfy.expect index fb90cb0b33c..c46279445c4 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression12.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression12.dfy.expect @@ -6,4 +6,4 @@ Regression12.dfy(65,7): Error: value of expression (of type 'set') is not Regression12.dfy(14,25): Error: value does not satisfy the subset constraints of 'int -> char' (possible cause: it may be partial or have read effects) Regression12.dfy(16,25): Error: value does not satisfy the subset constraints of 'int -> char' (possible cause: it may be partial or have read effects) -Dafny program verifier finished with 5 verified, 3 errors +Dafny program verifier finished with 3 verified, 3 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression5.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression5.dfy index 9b850042f8a..6301594e7ce 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression5.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/Regression5.dfy @@ -10,7 +10,7 @@ method P(x: int) returns (y: bv8) } method Q() { - var r: real := -3.0; + var r: int := -3; var v: bv8; v := r as bv8; // error: value most certainly is negative } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy index 9183113a292..c95f07cfdd2 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy @@ -5,5 +5,5 @@ ghost function Foo(m: map): seq ensures Foo(m) != [] lemma Bar() - ensures forall m | 0 in m :: Foo(m)[0] == m[0] // error (x3) -- but should not crash Dafny + ensures forall m | 0 in m :: Foo(m)[0] == m[0] // error -- but should not crash Dafny {} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy.expect index b16d937185a..b3917172050 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue149.dfy.expect @@ -1,4 +1,4 @@ -git-issue149.dfy(8,28): Error: the type of this variable is underspecified -git-issue149.dfy(8,36): Error: type parameter 'T' (inferred to be '?') in the function call to 'Foo' could not be determined -git-issue149.dfy(8,19): Error: type of bound variable 'm' could not be determined; please specify the type explicitly +git-issue149.dfy(8,28): Error: the type ('map') of this variable is underspecified +git-issue149.dfy(8,36): Error: type parameter 'T' (inferred to be '?16') in the function call to 'Foo' could not be determined +git-issue149.dfy(8,19): Error: type of bound variable 'm' could not be determined ('map'); please specify the type explicitly 3 resolution/type errors detected in git-issue149.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue182.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue182.dfy.expect index 592125f1b0b..abec4cffc29 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue182.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue182.dfy.expect @@ -1,3 +1,3 @@ -git-issue182.dfy(5,8): Error: Postcondition must be a boolean (got () -> bool) +git-issue182.dfy(5,8): Error: Postcondition must be a boolean (got () ~> bool) git-issue182.dfy(5,8): Error: cannot use naked function in recursive setting. Possible solution: eta expansion. 2 resolution/type errors detected in git-issue182.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue228.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue228.dfy.expect index b2a6fde9340..86a192a3725 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue228.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue228.dfy.expect @@ -168,6 +168,18 @@ module _System { } datatype /*_tuple#0*/ () = _#Make0 + + type bv0 { + function RotateLeft(w: nat): bv0 + + function RotateRight(w: nat): bv0 + } + + type bv19 { + function RotateLeft(w: nat): bv19 + + function RotateRight(w: nat): bv19 + } } // bitvector types in use: bv0 bv19 */ diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue254.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue254.dfy index f65bb1b95ca..ecf4ad55291 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue254.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue254.dfy @@ -3,7 +3,7 @@ class Foo {} -trait InputStream { +trait InputStream extends object { var x: int ghost predicate Valid() reads this method read(b: Foo) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue281.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue281.dfy.expect index 59d31b18c36..1917271e7ce 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue281.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue281.dfy.expect @@ -1,3 +1,3 @@ -git-issue281.dfy(13,25): Error: member Left does not exist in type DT -git-issue281.dfy(14,25): Error: member Left does not exist in type DT +git-issue281.dfy(13,25): Error: type 'DT' does not contain a datatype constructor 'Left' +git-issue281.dfy(14,25): Error: type 'DT' does not contain a datatype constructor 'Left' 2 resolution/type errors detected in git-issue281.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue67.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue67.dfy index d5ed865b644..9e7f603b792 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue67.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue67.dfy @@ -14,11 +14,11 @@ method MainMethod(y: Node) { AuxMethod(y); // remove this call and the assertion below goes through (as it should) - forall x | Q(x) + forall x: Node | Q(x) ensures P(x) { assume false; } // The following assertion should be a direct consequence of the forall statement above - assert forall x :: Q(x) ==> P(x); + assert forall x: Node :: Q(x) ==> P(x); } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue99.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue99.dfy.expect index a8a4c215934..6ddb32caf8d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue99.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafny4/git-issue99.dfy.expect @@ -1,3 +1,3 @@ git-issue99.dfy(6,22): Error: Type or type parameter is not declared in this scope: BOGUS_TYPE (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) -git-issue99.dfy(6,44): Error: second argument to "in" must be a set, multiset, or sequence with elements of type (BOGUS_TYPE, T2), or a map with domain (BOGUS_TYPE, T2) (instead got iset<(T1, T2)>) (expecting element type to be assignable to (T1, T2) (got (BOGUS_TYPE, T2))) +git-issue99.dfy(6,44): Error: expecting element type to be assignable to (T1, T2) (got ((), T2)) 2 resolution/type errors detected in git-issue99.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy index 7ed16d8f7c7..9693402106b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy @@ -174,7 +174,7 @@ module {:options "--function-syntax:4"} TestModule { ensures true - trait T1 extends T3 /** A special trait */ { + trait T1 extends object, T3 /** A special trait */ { const one := 1 var count: int } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/Simple_compiler/Compiler.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/Simple_compiler/Compiler.dfy index d542a65ea1b..95c41373780 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/Simple_compiler/Compiler.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/Simple_compiler/Compiler.dfy @@ -226,7 +226,7 @@ module StackMachine { case (PopAdd, _) => st case (PopSub, _) => st case (PopPrint, _) => st - case (PopVar, _) => st + case (PopVar(_), _) => st } } @@ -430,7 +430,7 @@ module {:extern "SimpleCompiler.CSharpAST"} CSharpAST { function {:extern} Equals(other: Op__BinOp): bool } - trait {:compile false} {:extern} Expr {} + trait {:compile false} {:extern} Expr extends object {} trait {:compile false} {:extern} Const extends Expr { var n: nativeint @@ -446,7 +446,7 @@ module {:extern "SimpleCompiler.CSharpAST"} CSharpAST { var e2: Expr } - trait {:compile false} {:extern} Stmt {} + trait {:compile false} {:extern} Stmt extends object {} trait {:compile false} {:extern} Print extends Stmt { var e: Expr @@ -457,7 +457,7 @@ module {:extern "SimpleCompiler.CSharpAST"} CSharpAST { var e: Expr } - trait {:compile false} {:extern} Prog { + trait {:compile false} {:extern} Prog extends object { var s: System.Collections.Generic.List } } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/EliminateMulZero.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/EliminateMulZero.dfy.expect index 9e74af046b4..94ea176b77c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/EliminateMulZero.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/EliminateMulZero.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 29 verified, 0 errors +Dafny program verifier finished with 30 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Equiv.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Equiv.dfy.expect index 94ea176b77c..5ed0d97333e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Equiv.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Equiv.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 30 verified, 0 errors +Dafny program verifier finished with 31 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy index bbd74918143..bcc065ec1f9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy @@ -117,7 +117,7 @@ abstract module Induction { requires e.Op? && e.op == op && e.oe1 == e1 && e.oe2 == e2 requires !P_Fail(st, e) ensures !P_Fail(st, e1) - ensures forall st1, v1 | P_Succ(st, e1, st1, v1) :: !P_Fail(st1, e2) + ensures forall st1: S, v1 | P_Succ(st, e1, st1, v1) :: !P_Fail(st1, e2) lemma InductOp_Succ(st: S, e: Expr, op: BinOp, e1: Expr, e2: Expr, st1: S, v1: V) requires e.Op? && e.op == op && e.oe1 == e1 && e.oe2 == e2 @@ -142,7 +142,7 @@ abstract module Induction { requires !P_Fail(st, e) requires Pes(st, avals) ensures !Pes_Fail(st, avals) - ensures forall st1, vs | Pes_Succ(st, avals, st1, vs) :: UpdateState_Pre(st1, avars, vs) + ensures forall st1: S, vs: VS | Pes_Succ(st, avals, st1, vs) :: UpdateState_Pre(st1, avars, vs) lemma InductAssign_Succ( st: S, e: Expr, avars: seq, avals: seq, st1: S, vs: VS, st2: S) @@ -162,7 +162,7 @@ abstract module Induction { requires Pes(st, bvals) ensures !Pes_Fail(st, bvals) ensures - forall st1, vs | Pes_Succ(st, bvals, st1, vs) :: + forall st1: S, vs: VS | Pes_Succ(st, bvals, st1, vs) :: && UpdateState_Pre(st1, bvars, vs) && !P_Fail(BindStartScope(st1, bvars, vs), body) @@ -183,8 +183,8 @@ abstract module Induction { lemma InductExprs_Cons(st: S, e: Expr, es: seq) ensures P_Fail(st, e) ==> Pes_Fail(st, [e] + es) - ensures !P_Fail(st, e) ==> forall st1, v :: P_Succ(st, e, st1, v) && Pes_Fail(st1, es) ==> Pes_Fail(st, [e] + es) - ensures forall st1, v, st2, vs :: P_Succ(st, e, st1, v) && Pes_Succ(st1, es, st2, vs) ==> Pes_Succ(st, [e] + es, st2, AppendValue(v, vs)) + ensures !P_Fail(st, e) ==> forall st1: S, v :: P_Succ(st, e, st1, v) && Pes_Fail(st1, es) ==> Pes_Fail(st, [e] + es) + ensures forall st1: S, v, st2: S, vs: VS :: P_Succ(st, e, st1, v) && Pes_Succ(st1, es, st2, vs) ==> Pes_Succ(st, [e] + es, st2, AppendValue(v, vs)) // // Lemmas diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy.expect index 15301952c57..9b96db8633f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Induction.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 16 verified, 0 errors +Dafny program verifier finished with 17 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Pure.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Pure.dfy.expect index be068182e1e..2532f627752 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Pure.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/Pure.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 25 verified, 0 errors +Dafny program verifier finished with 26 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/VarUnchanged.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/VarUnchanged.dfy.expect index 8a923ac640e..94ea176b77c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/VarUnchanged.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/induction-principle-code/VarUnchanged.dfy.expect @@ -1,2 +1,2 @@ -Dafny program verifier finished with 28 verified, 0 errors +Dafny program verifier finished with 30 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/parser_combinators.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/parser_combinators.dfy.expect index 34fc88fa5b1..4036f11eb48 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/parser_combinators.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/examples/parser_combinators.dfy.expect @@ -1,6 +1,6 @@ parser_combinators.dfy(39,35): Error: cannot prove termination; try supplying a decreases clause -Dafny program verifier finished with 8 verified, 1 error +Dafny program verifier finished with 9 verified, 1 error Dafny program verifier did not attempt verification "((()))": 3 nested parentheses diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exceptions/TypecheckErrors.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exceptions/TypecheckErrors.dfy.refresh.expect index bc5158e0762..14c3b1f4637 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exceptions/TypecheckErrors.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exceptions/TypecheckErrors.dfy.refresh.expect @@ -1,12 +1,14 @@ -TypecheckErrors.dfy(7,29): Error: string literal used as if it had type int -TypecheckErrors.dfy(8,29): Error: string literal used as if it had type int +TypecheckErrors.dfy(7,29): Error: string literal "not a nat" used as if it had type int +TypecheckErrors.dfy(8,29): Error: string literal "not a nat either" used as if it had type int +TypecheckErrors.dfy(7,29): Error: string literal "not a nat" used as if it had type int +TypecheckErrors.dfy(8,29): Error: string literal "not a nat either" used as if it had type int TypecheckErrors.dfy(39,10): Error: member IsFailure does not exist in BadOutcome1, in :- statement TypecheckErrors.dfy(43,10): Error: member 'PropagateFailure' does not exist in trait 'BadOutcome2' TypecheckErrors.dfy(43,10): Error: The right-hand side of ':-', which is of type 'BadOutcome2', must have functions 'IsFailure()', 'PropagateFailure()', and 'Extract()' TypecheckErrors.dfy(47,10): Error: number of lhs (1) must be one less than number of rhs (1) for a rhs type (BadOutcome3) without member Extract -TypecheckErrors.dfy(51,23): Error: integer literal used as if it had type seq +TypecheckErrors.dfy(51,23): Error: integer literal used as if it had type string TypecheckErrors.dfy(71,4): Error: member IsFailure does not exist in BadVoidOutcome1, in :- statement TypecheckErrors.dfy(75,4): Error: member 'PropagateFailure' does not exist in trait 'BadVoidOutcome2' TypecheckErrors.dfy(75,4): Error: The right-hand side of ':-', which is of type 'BadVoidOutcome2', must have functions 'IsFailure()' and 'PropagateFailure()', but not 'Extract()' TypecheckErrors.dfy(79,4): Error: number of lhs (0) must match number of rhs (1) for a rhs type (BadVoidOutcome3) with member Extract -11 resolution/type errors detected in TypecheckErrors.dfy +13 resolution/type errors detected in TypecheckErrors.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/AggregateImport.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/AggregateImport.dfy.expect index 7d67de2d8ab..4f7da840b21 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/AggregateImport.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/AggregateImport.dfy.expect @@ -1,4 +1,4 @@ AggregateImport.dfy(32,16): Error: module 'A' does not declare a type 'TT' -AggregateImport.dfy(45,16): Error: arguments must have comparable types (got A.T and bool) -AggregateImport.dfy(46,17): Error: arguments must have comparable types (got A.TT and int) +AggregateImport.dfy(45,19): Error: boolean literal used as if it had type T +AggregateImport.dfy(46,20): Error: integer literal used as if it had type TT 3 resolution/type errors detected in AggregateImport.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DatatypeExport.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DatatypeExport.dfy.expect index 02284391a54..6f3a737aee6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DatatypeExport.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DatatypeExport.dfy.expect @@ -1,6 +1,7 @@ DatatypeExport.dfy(41,30): Error: unresolved identifier: CT1 -DatatypeExport.dfy(46,11): Error: member CT2 does not exist in type A.T +DatatypeExport.dfy(46,11): Error: type 'T' does not contain a datatype constructor 'CT2' +DatatypeExport.dfy(46,21): Error: unresolved identifier: n DatatypeExport.dfy(48,40): Error: member 'CT1?' has not been imported in this scope and cannot be accessed here DatatypeExport.dfy(48,59): Error: member 'X' has not been imported in this scope and cannot be accessed here DatatypeExport.dfy(56,30): Error: unresolved identifier: CT1 -5 resolution/type errors detected in DatatypeExport.dfy +6 resolution/type errors detected in DatatypeExport.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DefaultExport.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DefaultExport.dfy.expect index 98adecbf073..efe33fb3971 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DefaultExport.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/DefaultExport.dfy.expect @@ -1,5 +1,5 @@ -DefaultExport.dfy(13,16): Error: arguments must have comparable types (got A.T and bool) -DefaultExport.dfy(25,16): Error: arguments must have comparable types (got D.T and bool) +DefaultExport.dfy(13,19): Error: boolean literal used as if it had type T +DefaultExport.dfy(25,19): Error: boolean literal used as if it had type T DefaultExport.dfy(33,2): Error: duplicate name of export set: E DefaultExport.dfy(31,7): Error: more than one default export set declared in module E 4 resolution/type errors detected in DefaultExport.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportImport.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportImport.dfy.expect index c57b06a12c2..75c38afd79f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportImport.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportImport.dfy.expect @@ -1,5 +1,5 @@ ExportImport.dfy(34,17): Error: module BAO does not exist (position 1 in path B.BAO) ExportImport.dfy(39,18): Error: module BAO does not exist (position 1 in path B.BAO) -ExportImport.dfy(48,18): Error: arguments must have comparable types (got DAO.T and bool) -ExportImport.dfy(51,18): Error: arguments must have comparable types (got DAO.T and B.TT) +ExportImport.dfy(48,21): Error: boolean literal used as if it had type T +ExportImport.dfy(51,18): Error: arguments must have comparable types (got T and TT) 4 resolution/type errors detected in ExportImport.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy index df42866061e..0a6a42f7279 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy @@ -46,7 +46,7 @@ module NamesThatDontExist { provides Dt.Cons? // error: datatype discriminators cannot be individually exported provides Dt.u // error: datatype denstructors cannot be individually exported - trait Trait { + trait Trait extends object { ghost predicate Valid() { true } method M() { } var x: int @@ -132,7 +132,7 @@ module ConsistencyErrors { provides Trait.M, Trait.N, Trait.x provides Klass.M, Klass.N, Klass.x - trait Trait { + trait Trait extends object { ghost predicate Valid() { true } const M := 100 static const N := 101 @@ -209,7 +209,7 @@ module GoodExports { reveals Klass provides Klass.FromInt - trait Trait { + trait Trait extends object { ghost predicate Valid() { true } const M := 100 static const N := 101 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy.expect index 0fcffd944ea..129e83458dd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/ExportResolve.dfy.expect @@ -67,8 +67,8 @@ ExportResolve.dfy(175,9): Error: This export set is not consistent: WhatIsKnownA ExportResolve.dfy(248,20): Error: unresolved identifier: X ExportResolve.dfy(248,28): Error: member 'More?' has not been imported in this scope and cannot be accessed here ExportResolve.dfy(248,39): Error: member 'u' has not been imported in this scope and cannot be accessed here -ExportResolve.dfy(250,18): Error: type of corresponding source/RHS (G.Trait) does not match type of bound variable (object?) -ExportResolve.dfy(250,46): Error: type of corresponding source/RHS (G.Klass) does not match type of bound variable (object?) +ExportResolve.dfy(250,18): Error: type of corresponding source/RHS (Trait) does not match type of bound variable (object?) +ExportResolve.dfy(250,46): Error: type of corresponding source/RHS (Klass) does not match type of bound variable (object?) ExportResolve.dfy(252,15): Error: member 'Valid' has not been imported in this scope and cannot be accessed here ExportResolve.dfy(252,28): Error: member 'Valid' has not been imported in this scope and cannot be accessed here ExportResolve.dfy(252,41): Error: member 'Valid' has not been imported in this scope and cannot be accessed here @@ -91,17 +91,17 @@ ExportResolve.dfy(277,29): Error: member 'M' has not been imported in this scope ExportResolve.dfy(288,20): Error: unresolved identifier: X ExportResolve.dfy(288,28): Error: member 'More?' has not been imported in this scope and cannot be accessed here ExportResolve.dfy(288,39): Error: member 'u' has not been imported in this scope and cannot be accessed here -ExportResolve.dfy(290,18): Error: type of corresponding source/RHS (G.Trait) does not match type of bound variable (object?) -ExportResolve.dfy(290,46): Error: type of corresponding source/RHS (G.Klass) does not match type of bound variable (object?) +ExportResolve.dfy(290,18): Error: type of corresponding source/RHS (Trait) does not match type of bound variable (object?) +ExportResolve.dfy(290,46): Error: type of corresponding source/RHS (Klass) does not match type of bound variable (object?) ExportResolve.dfy(298,19): Error: member '_ctor' has not been imported in this scope and cannot be accessed here ExportResolve.dfy(342,15): Error: cannot reveal 'OpaqueFunction' because no revealable constant, function, assert label, or requires label in the current scope is named 'OpaqueFunction' +ExportResolve.dfy(410,8): Error: RHS (of type X) not assignable to LHS (of type Z) +ExportResolve.dfy(411,8): Error: RHS (of type T) not assignable to LHS (of type Z) ExportResolve.dfy(414,15): Error: member 'Q' has not been imported in this scope and cannot be accessed here -ExportResolve.dfy(410,8): Error: RHS (of type C.X) not assignable to LHS (of type C.Z) -ExportResolve.dfy(411,8): Error: RHS (of type A.T) not assignable to LHS (of type C.Z) -ExportResolve.dfy(412,8): Error: RHS (of type int) not assignable to LHS (of type A.T) +ExportResolve.dfy(412,11): Error: integer literal used as if it had type T +ExportResolve.dfy(432,8): Error: RHS (of type X) not assignable to LHS (of type Z) +ExportResolve.dfy(433,8): Error: RHS (of type T) not assignable to LHS (of type Z) ExportResolve.dfy(436,15): Error: member 'Q' has not been imported in this scope and cannot be accessed here -ExportResolve.dfy(432,8): Error: RHS (of type C.X) not assignable to LHS (of type C.Z) -ExportResolve.dfy(433,8): Error: RHS (of type A.T) not assignable to LHS (of type C.Z) ExportResolve.dfy(457,15): Error: member 'Q' has not been imported in this scope and cannot be accessed here ExportResolve.dfy(473,15): Error: Cannot export mutable field 'u' without revealing its enclosing class 'C' ExportResolve.dfy(475,15): Error: Cannot export constructor 'FromInt' without revealing its enclosing class 'C' diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy index 56fb575515f..84bb5bb714a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy @@ -1,19 +1,19 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" +// RUN: %exits-with 2 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" module A { export A provides T, f export B extends A reveals T type T = nat - ghost function f() : T + ghost function f(): T } module B { import A`A - ghost function G() : nat { A.f() } // error, T not known to be nat + ghost function G(): nat { A.f() } // error, T not known to be nat - ghost function H(n : A.T) : bool - requires 0 <= n; // error + ghost function H(n: A.T): bool + requires 0 <= n // error } @@ -22,8 +22,8 @@ module C { ghost function G(): nat { A.f() } // T is now known - ghost function H(n : A.T, m : A.T, h : nat) : bool - requires 0 <= n && n == m && h <= m; + ghost function H(n: A.T, m: A.T, h: nat): bool + requires 0 <= n && n == m && h <= m } @@ -32,15 +32,15 @@ module AA { export A provides T, f export B extends A reveals T newtype T = x: nat | 0 <= x < 3 && [5, 7, 8][x] % 2 != 0 - ghost function f() : T + ghost function f(): T } module BB { import A = AA`A - ghost function G() : int { A.f() as int } // error, T not known to be nat + ghost function G(): int { A.f() as int } // error, T not known to be nat - ghost function H(n : A.T) : bool - requires 0 <= n; // error + ghost function H(n: A.T): bool + requires 0 <= n // error } @@ -49,9 +49,7 @@ module CC { ghost function G(): nat { A.f() as int } // T is now known - ghost function H(n : A.T, m : A.T) : bool - requires 0 <= n && n == m && 1 <= m; + ghost function H(n: A.T, m: A.T): bool + requires 0 <= n && n == m && 1 <= m } - - diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy.expect index 2f69ccad290..9aa6b2cb168 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/OpaqueTypes.dfy.expect @@ -1,5 +1,7 @@ OpaqueTypes.dfy(13,17): Error: Function body type mismatch (expected nat, got T) -OpaqueTypes.dfy(16,13): Error: arguments to <= must have a common supertype (got int and A.T) -OpaqueTypes.dfy(40,35): Error: type conversion to an int-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got T) -OpaqueTypes.dfy(43,13): Error: arguments to <= must have a common supertype (got int and A.T) -4 resolution/type errors detected in OpaqueTypes.dfy +OpaqueTypes.dfy(16,13): Error: integer literal used as if it had type T +OpaqueTypes.dfy(16,15): Error: arguments to <= must be of a numeric type, bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got T) +OpaqueTypes.dfy(40,34): Error: type conversion to an int-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got T) +OpaqueTypes.dfy(43,13): Error: integer literal used as if it had type T +OpaqueTypes.dfy(43,15): Error: arguments to <= must be of a numeric type, bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got T) +6 resolution/type errors detected in OpaqueTypes.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/SubModuleDefaultExport.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/SubModuleDefaultExport.dfy.expect index 0837222ffdb..b4fd4437b5f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/SubModuleDefaultExport.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/exports/SubModuleDefaultExport.dfy.expect @@ -1,3 +1,3 @@ SubModuleDefaultExport.dfy(15,17): Error: module 'SubE' does not declare a type 'TT' -SubModuleDefaultExport.dfy(18,15): Error: arguments must have comparable types (got SubE.T and bool) +SubModuleDefaultExport.dfy(18,18): Error: boolean literal used as if it had type T 2 resolution/type errors detected in SubModuleDefaultExport.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-032-errors.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-032-errors.dfy.expect index fe740273a30..8608305cb84 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-032-errors.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-032-errors.dfy.expect @@ -1,7 +1,7 @@ -git-issue-032-errors.dfy(8,17): Error: the case pattern is a 0-element tuple, while the match expression is a 2-element tuple -git-issue-032-errors.dfy(9,17): Error: the case pattern is a 2-element tuple, while the match expression is a 0-element tuple -git-issue-032-errors.dfy(10,18): Error: the case pattern is a 2-element tuple, while the match expression is a 0-element tuple -git-issue-032-errors.dfy(11,26): Error: the case pattern is a 0-element tuple, while the match expression is a 2-element tuple -git-issue-032-errors.dfy(12,26): Error: the case pattern is a 2-element tuple, while the match expression is a 0-element tuple -git-issue-032-errors.dfy(13,27): Error: the case pattern is a 2-element tuple, while the match expression is a 0-element tuple +git-issue-032-errors.dfy(8,17): Error: tuple type does not match type '(int, int)' +git-issue-032-errors.dfy(9,17): Error: tuple type does not match type '()' +git-issue-032-errors.dfy(10,18): Error: tuple type does not match type '()' +git-issue-032-errors.dfy(11,26): Error: tuple type does not match type '(int, int)' +git-issue-032-errors.dfy(12,26): Error: tuple type does not match type '()' +git-issue-032-errors.dfy(13,27): Error: tuple type does not match type '()' 6 resolution/type errors detected in git-issue-032-errors.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1005.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1005.dfy.expect index cbdd5c42ba1..9c87bb2b32c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1005.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1005.dfy.expect @@ -1,28 +1,28 @@ -git-issue-1005.dfy(11,8): Error: wrong number of arguments (got 0, but datatype constructor 'S1' expects 1: (a0: int)) -git-issue-1005.dfy(12,8): Error: wrong number of arguments (got 0, but datatype constructor 'S2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(13,8): Error: wrong number of arguments (got 0, but datatype constructor 'S3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(18,8): Error: wrong number of arguments (got 0, but datatype constructor 'S1' expects 1: (a0: int)) -git-issue-1005.dfy(19,8): Error: wrong number of arguments (got 0, but datatype constructor 'S2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(20,8): Error: wrong number of arguments (got 0, but datatype constructor 'S3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(24,8): Error: wrong number of arguments (got 1, but datatype constructor 'S0' expects 0) -git-issue-1005.dfy(26,8): Error: wrong number of arguments (got 1, but datatype constructor 'S2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(27,8): Error: wrong number of arguments (got 1, but datatype constructor 'S3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(31,8): Error: wrong number of arguments (got 4, but datatype constructor 'S0' expects 0) -git-issue-1005.dfy(32,8): Error: wrong number of arguments (got 4, but datatype constructor 'S1' expects 1: (a0: int)) -git-issue-1005.dfy(33,8): Error: wrong number of arguments (got 4, but datatype constructor 'S2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(34,8): Error: wrong number of arguments (got 4, but datatype constructor 'S3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(44,8): Error: wrong number of arguments (got 0, but datatype constructor 'C1' expects 1: (a0: int)) -git-issue-1005.dfy(45,8): Error: wrong number of arguments (got 0, but datatype constructor 'C2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(46,8): Error: wrong number of arguments (got 0, but datatype constructor 'C3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(51,8): Error: wrong number of arguments (got 0, but datatype constructor 'C1' expects 1: (a0: int)) -git-issue-1005.dfy(52,8): Error: wrong number of arguments (got 0, but datatype constructor 'C2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(53,8): Error: wrong number of arguments (got 0, but datatype constructor 'C3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(57,8): Error: wrong number of arguments (got 1, but datatype constructor 'C0' expects 0) -git-issue-1005.dfy(59,8): Error: wrong number of arguments (got 1, but datatype constructor 'C2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(60,8): Error: wrong number of arguments (got 1, but datatype constructor 'C3' expects 3: (a0: int, a1: int, a2: int)) -git-issue-1005.dfy(64,8): Error: wrong number of arguments (got 4, but datatype constructor 'C0' expects 0) -git-issue-1005.dfy(65,8): Error: wrong number of arguments (got 4, but datatype constructor 'C1' expects 1: (a0: int)) -git-issue-1005.dfy(66,8): Error: wrong number of arguments (got 4, but datatype constructor 'C2' expects 2: (a0: int, a1: int)) -git-issue-1005.dfy(67,8): Error: wrong number of arguments (got 4, but datatype constructor 'C3' expects 3: (a0: int, a1: int, a2: int)) +git-issue-1005.dfy(11,8): Error: wrong number of arguments (datatype constructor 'S1' expects 1, got 0) +git-issue-1005.dfy(12,8): Error: wrong number of arguments (datatype constructor 'S2' expects 2, got 0) +git-issue-1005.dfy(13,8): Error: wrong number of arguments (datatype constructor 'S3' expects 3, got 0) +git-issue-1005.dfy(18,8): Error: wrong number of arguments (datatype constructor 'S1' expects 1, got 0) +git-issue-1005.dfy(19,8): Error: wrong number of arguments (datatype constructor 'S2' expects 2, got 0) +git-issue-1005.dfy(20,8): Error: wrong number of arguments (datatype constructor 'S3' expects 3, got 0) +git-issue-1005.dfy(24,8): Error: wrong number of arguments (datatype constructor 'S0' expects 0, got 1) +git-issue-1005.dfy(26,8): Error: wrong number of arguments (datatype constructor 'S2' expects 2, got 1) +git-issue-1005.dfy(27,8): Error: wrong number of arguments (datatype constructor 'S3' expects 3, got 1) +git-issue-1005.dfy(31,8): Error: wrong number of arguments (datatype constructor 'S0' expects 0, got 4) +git-issue-1005.dfy(32,8): Error: wrong number of arguments (datatype constructor 'S1' expects 1, got 4) +git-issue-1005.dfy(33,8): Error: wrong number of arguments (datatype constructor 'S2' expects 2, got 4) +git-issue-1005.dfy(34,8): Error: wrong number of arguments (datatype constructor 'S3' expects 3, got 4) +git-issue-1005.dfy(44,8): Error: wrong number of arguments (datatype constructor 'C1' expects 1, got 0) +git-issue-1005.dfy(45,8): Error: wrong number of arguments (datatype constructor 'C2' expects 2, got 0) +git-issue-1005.dfy(46,8): Error: wrong number of arguments (datatype constructor 'C3' expects 3, got 0) +git-issue-1005.dfy(51,8): Error: wrong number of arguments (datatype constructor 'C1' expects 1, got 0) +git-issue-1005.dfy(52,8): Error: wrong number of arguments (datatype constructor 'C2' expects 2, got 0) +git-issue-1005.dfy(53,8): Error: wrong number of arguments (datatype constructor 'C3' expects 3, got 0) +git-issue-1005.dfy(57,8): Error: wrong number of arguments (datatype constructor 'C0' expects 0, got 1) +git-issue-1005.dfy(59,8): Error: wrong number of arguments (datatype constructor 'C2' expects 2, got 1) +git-issue-1005.dfy(60,8): Error: wrong number of arguments (datatype constructor 'C3' expects 3, got 1) +git-issue-1005.dfy(64,8): Error: wrong number of arguments (datatype constructor 'C0' expects 0, got 4) +git-issue-1005.dfy(65,8): Error: wrong number of arguments (datatype constructor 'C1' expects 1, got 4) +git-issue-1005.dfy(66,8): Error: wrong number of arguments (datatype constructor 'C2' expects 2, got 4) +git-issue-1005.dfy(67,8): Error: wrong number of arguments (datatype constructor 'C3' expects 3, got 4) git-issue-1005.dfy(71,11): Error: unresolved identifier: R5 27 resolution/type errors detected in git-issue-1005.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy index b93d4e9f9a9..e1352b87235 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy @@ -114,7 +114,7 @@ method Test4(process: Process, m: map, log: seq) var last :- Find(process, log); Some(100); - var c := x == z; // ERROR: this should give a type error + var c := x == z; // ERROR: this (or the literal 100 above) should give a type error } method Test5(s: State) @@ -126,6 +126,6 @@ method Test5(s: State) var n :- Gimmie(); Some(100.0); - var c := x == z; // ERROR: this should give a type error + var c := x == z; // ERROR: this (or the literal 100.0 above) should give a type error } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy.expect index b0b5067445c..9ff83ad96dd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016.dfy.expect @@ -1,6 +1,6 @@ git-issue-1016.dfy(66,13): Error: arguments must have comparable types (got Option and Option) git-issue-1016.dfy(82,13): Error: arguments must have comparable types (got Option and Option) git-issue-1016.dfy(101,13): Error: arguments must have comparable types (got Option and Option) -git-issue-1016.dfy(117,13): Error: arguments must have comparable types (got Option and Option) -git-issue-1016.dfy(129,13): Error: arguments must have comparable types (got Option and Option) +git-issue-1016.dfy(115,9): Error: integer literal used as if it had type State +git-issue-1016.dfy(127,9): Error: real literal used as if it had type State 5 resolution/type errors detected in git-issue-1016.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy index 50bc2e5c604..993e9419041 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy @@ -31,6 +31,6 @@ method Test5(s: State) var n :- Gimmie(); Some(100.0); - var c := x == z; // ERROR: this should give a type error + var c := x == z; // ERROR: this (or the literal 100.0 above) should give a type error } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy.expect index 2411f6bb965..24101e18ef9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1016a.dfy.expect @@ -1,2 +1,2 @@ -git-issue-1016a.dfy(34,13): Error: arguments must have comparable types (got Option and Option) +git-issue-1016a.dfy(32,9): Error: real literal used as if it had type State 1 resolution/type errors detected in git-issue-1016a.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1148.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1148.dfy index c81d05cbaa7..239af68a517 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1148.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1148.dfy @@ -23,7 +23,7 @@ module AutoInitRegressions { const InstanceField: Y } - trait Trait { + trait Trait extends object { static const StaticField: Y // error: Y is not auto-init const InstanceField: Y } @@ -60,7 +60,7 @@ module NonemptyRegressions { ghost const InstanceField: Y } - trait Trait { + trait Trait extends object { ghost static const StaticField: Y // error: Y is not nonempty ghost const InstanceField: Y } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1180b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1180b.dfy index 03746a917e9..ab1d68893fd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1180b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1180b.dfy @@ -58,7 +58,7 @@ module StartingFromOpaqueType { } } module Trait refines A { - trait Ty { + trait Ty extends object { var q: int function F(x: nat): nat { x } // error: postcondition violation method M(x: nat) returns (r: nat) { r := c; } // error: postcondition violation diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy index 38074794880..953356b33f9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy @@ -1,7 +1,7 @@ // RUN: %exits-with 4 %run "%s" > "%t" // RUN: %diff "%s.expect" "%t" -trait H { var data: Y } +trait H extends object { var data: Y } class K extends H { } type Singleton = () @@ -10,7 +10,7 @@ method Main() { var k := new K; var a: H := k; var b: H := BadCast(k); - assert a == k == b; + assert a == k == b as object; label L: var x := a.data; Change(a); @@ -21,10 +21,10 @@ method Main() { } ghost method BadCast(k: K) returns (b: H) - ensures b == k + ensures b == k as object { var oo: object := k; - b := oo; // error: this was once not caught by the verifier + b := oo as H; // error: this was once not caught by the verifier } method Change(a: H) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy.expect index e875f206ddf..5e1ee580623 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1212.dfy.expect @@ -1,3 +1,3 @@ -git-issue-1212.dfy(27,7): Error: value of expression (of type 'object') is not known to be an instance of type 'H' +git-issue-1212.dfy(27,10): Error: value of expression (of type 'object') is not known to be an instance of type 'H' Dafny program verifier finished with 5 verified, 1 error diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1256.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1256.dfy index b952c42bc34..d589217998d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1256.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1256.dfy @@ -15,8 +15,8 @@ method False() ensures false { var x: int := f(); - var y: low_int := f(); - var z: high_int := f(); + var y: low_int := f(); + var z: high_int := f(); // Regression: the following assertions were once provable assert x == y; // error assert x == z; // error diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy index b3d1913b781..9da9775ba92 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %baredafny verify --allow-axioms --show-snippets:false --use-basename-for-filename "%s" > "%t" +// RUN: %exits-with 2 %verify --allow-axioms "%s" > "%t" // RUN: %diff "%s.expect" "%t" // Example for Issue 1309 -- not yet fixed @@ -12,7 +12,6 @@ module A { module B { module C { datatype Option = None | Some(x : T) - } } @@ -21,6 +20,6 @@ module D { import B lemma Bad(x: int) - ensures A.C.Some(x) == B.C.Some(x) + ensures A.C.Some(x) == B.C.Some(x) // error, but gives a confusing error message } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy.expect index 327417a8443..d201dbd12d6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1309.dfy.expect @@ -1,2 +1,2 @@ -git-issue-1309.dfy(24,22): Error: arguments must have comparable types (got C.Option and C.Option) +git-issue-1309.dfy(23,24): Error: arguments must have comparable types (got Option and Option) 1 resolution/type errors detected in git-issue-1309.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1373.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1373.dfy.expect index 9963d8ab5ca..1a9963b4f72 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1373.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1373.dfy.expect @@ -1,3 +1,3 @@ -git-issue-1373.dfy(6,10): Error: Cannot compute the set of Values because the type of the range of the map (() ~> int) does not support equality. -git-issue-1373.dfy(7,10): Error: Cannot compute the set of Items because the type of the range of the map (() ~> int) does not support equality. +git-issue-1373.dfy(6,10): Error: Cannot compute the set of Values because the type of the range of the map (() -> int) does not support equality. +git-issue-1373.dfy(7,10): Error: Cannot compute the set of Items because the type of the range of the map (() -> int) does not support equality. 2 resolution/type errors detected in git-issue-1373.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1514b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1514b.dfy index 876880c5298..9e6ad623c87 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1514b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1514b.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --standard-libraries --relax-definite-assignment +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false --standard-libraries --relax-definite-assignment import opened Std.Wrappers diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604.dfy index 6df392a97b5..902ef3f588d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604.dfy @@ -1,6 +1,6 @@ // RUN: %testDafnyForEachCompiler "%s" -trait Tr { } +trait Tr extends object { } class A extends Tr { } class B extends Tr { } @@ -11,7 +11,7 @@ ghost predicate SpecialA(a: A) type Ap = x : A | SpecialA(x) witness * function testSpecial(x: Tr): bool - requires x is A && SpecialA(x) + requires x is A && SpecialA(x as A) { 1/0 == 0 } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy index 77b0e02a72e..7f2c9311c03 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy @@ -9,9 +9,13 @@ method NatTypeInferenceType() { assert forall x: int :: EvenNat(x) ==> TrueInt(x); // precondition violation, since EvenNat expects a nat and x is int assert forall x: int :: 0 <= x && EvenNat(x) ==> TrueInt(x); // good assert forall x: int :: EvenNat(x) && 0 <= x ==> TrueInt(x); // precondition violation (good) - assert forall n :: EvenNat(n) ==> TrueInt(n); // since n is inferred to be an int, an precondition violation is reported + assert forall n :: EvenNat(n) ==> TrueInt(n); // since n is inferred to be an int, a precondition violation is reported - // In the following, n should be inferred as a nat - assert forall n | EvenNat(n) :: n == n; - assert forall n :: EvenNat(n) ==> true; -} \ No newline at end of file + // In the following, n is inferred as int + assert forall n | EvenNat(n) :: n == n; // error: n may be negative + assert forall n :: EvenNat(n) ==> true; // error: n may be negative + + // These work, even with the inferred type int + assert forall n: nat | EvenNat(n) :: n == n; + assert forall n :: 0 <= n && EvenNat(n) ==> true; +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy.expect index a15462da6cb..67ef040626e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1604c.dfy.expect @@ -1,5 +1,7 @@ git-issue-1604c.dfy(9,34): Error: value does not satisfy the subset constraints of 'nat' git-issue-1604c.dfy(11,34): Error: value does not satisfy the subset constraints of 'nat' git-issue-1604c.dfy(12,29): Error: value does not satisfy the subset constraints of 'nat' +git-issue-1604c.dfy(15,28): Error: value does not satisfy the subset constraints of 'nat' +git-issue-1604c.dfy(16,29): Error: value does not satisfy the subset constraints of 'nat' -Dafny program verifier finished with 1 verified, 3 errors +Dafny program verifier finished with 1 verified, 5 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1637.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1637.dfy.expect index ff37b311dbe..8aa6bdee1b8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1637.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1637.dfy.expect @@ -1,2 +1,2 @@ -git-issue-1637.dfy(19,6): Error: incorrect argument type for predicate parameter 'f' (expected Thing -> seq, found Thing -> Fii) (covariance for type parameter at index 1 expects seq :> Fii) +git-issue-1637.dfy(19,6): Error: incorrect argument type for predicate parameter 'f' (expected Thing -> seq, found Thing ~> Fii) (covariant type parameter 'R' would require seq :> Fii) 1 resolution/type errors detected in git-issue-1637.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy index 1e0c3fb10aa..e5df07fd3a3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy @@ -271,3 +271,21 @@ module ReferenceTypes { } } } + +module ExplicitTypeParameters { + function FId(t: T): T { t } + method MId(z: T) returns (r: T) { r := z; } + datatype Record = Record(g: T) + + method Test(u: int) + ensures true + { + if * { + var vv := FId(u); // error: u may be negative + } else if * { + var qq := MId(u); // error: u may be negative + } else { + var rr := Record.Record(u); // error: u may be negative + } + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy.expect index 8d2d05759db..c5abe113d2d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1676.dfy.expect @@ -24,5 +24,8 @@ git-issue-1676.dfy(212,47): Error: value of expression (of type 'multiset' git-issue-1676.dfy(213,47): Error: value of expression (of type 'multiset') is not known to be an instance of type 'multiset' git-issue-1676.dfy(224,40): Error: value does not satisfy the subset constraints of 'MyOrdinal' git-issue-1676.dfy(225,40): Error: value does not satisfy the subset constraints of 'MyOrdinal' +git-issue-1676.dfy(284,25): Error: value does not satisfy the subset constraints of 'nat' +git-issue-1676.dfy(286,25): Error: value does not satisfy the subset constraints of 'nat' +git-issue-1676.dfy(288,35): Error: value does not satisfy the subset constraints of 'nat' -Dafny program verifier finished with 19 verified, 26 errors +Dafny program verifier finished with 20 verified, 29 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1700.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1700.dfy.expect index 59ad783761b..6e647c3304e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1700.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1700.dfy.expect @@ -1,2 +1,2 @@ -git-issue-1700.dfy(15,21): Error: incorrect argument type for datatype constructor parameter 'e' (expected B.E, found A.E) +git-issue-1700.dfy(15,21): Error: incorrect argument type for datatype constructor parameter 'e' (expected E, found E) 1 resolution/type errors detected in git-issue-1700.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1887.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1887.dfy index 1a000986fd7..7905ba0eefc 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1887.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1887.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" function selectOneConstraint(s: seq): seq { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1996.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1996.dfy index 61abae81827..dbb48526858 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1996.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-1996.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module M { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2013.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2013.dfy index 1f3962988ee..715b18b0830 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2013.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2013.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment --type-system-refresh=false --general-traits=legacy --general-newtypes=false method Main() { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2019.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2019.dfy index f2beb5fde0e..98d451919c2 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2019.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2019.dfy @@ -1,5 +1,5 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" -// RUN: %diff "%s.expect" "%t" +// RUN: %testDafnyForEachResolver --expect-exit-code=2 "%s" + method f(x: seq) returns (res: seq) ensures x == res diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy new file mode 100644 index 00000000000..053cf0e826f --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy @@ -0,0 +1,14 @@ +// RUN: %testDafnyForEachResolver --expect-exit-code=2 "%s" + +class C { + var x: int +} + +datatype D = B(c: C) + +predicate P(d: D) + // the following line once caused a crash in the resolver + reads B.c // error: wrong number of arguments to B +{ + d.c.x >= 0 +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy.expect new file mode 100644 index 00000000000..e2897bbaa2e --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy.expect @@ -0,0 +1,2 @@ +git-issue-2040.dfy(11,8): Error: wrong number of arguments (got 0, but datatype constructor 'B' expects 1: (c: C)) +1 resolution/type errors detected in git-issue-2040.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy.refresh.expect new file mode 100644 index 00000000000..23ef90446f9 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2040.dfy.refresh.expect @@ -0,0 +1,2 @@ +git-issue-2040.dfy(11,8): Error: wrong number of arguments (datatype constructor 'B' expects 1, got 0) +1 resolution/type errors detected in git-issue-2040.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2068.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2068.dfy.expect index 52d33315586..ef459414458 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2068.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2068.dfy.expect @@ -1,4 +1,4 @@ git-issue-2068.dfy(5,19): Error: 'this' is not allowed in a 'static' context -git-issue-2068.dfy(10,51): Error: 'this' is not allowed in a 'static' context git-issue-2068.dfy(4,34): Error: 'this' is not allowed in a 'static' context +git-issue-2068.dfy(10,51): Error: 'this' is not allowed in a 'static' context 3 resolution/type errors detected in git-issue-2068.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2074.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2074.dfy.expect index f6450381332..e472164b906 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2074.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2074.dfy.expect @@ -1,4 +1,4 @@ -git-issue-2074.dfy(5,6): Error: the type of this variable is underspecified +git-issue-2074.dfy(5,6): Error: the type ('?5 ~> set') of this variable is underspecified git-issue-2074.dfy(5,25): Error: the type of this variable is underspecified git-issue-2074.dfy(5,21): Error: type of bound variable 'x' could not be determined; please specify the type explicitly git-issue-2074.dfy(5,11): Error: type of bound variable 'st' could not be determined; please specify the type explicitly diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2106.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2106.dfy.expect index 4b04d7f0ecc..be20ef31e29 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2106.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2106.dfy.expect @@ -1,2 +1,2 @@ -git-issue-2106.dfy(5,27): Error: wrong number of arguments (got 0, but predicate 'P' expects 1: (x: bool)) +git-issue-2106.dfy(5,27): Error: wrong number of arguments (predicate 'P' expects 1, got 0) 1 resolution/type errors detected in git-issue-2106.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2111.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2111.dfy.expect index e3e65961ac8..4fa9ce67ba9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2111.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2111.dfy.expect @@ -1,2 +1,2 @@ -git-issue-2111.dfy(6,4): Error: wrong number of arguments (got 0, but datatype constructor 'C' expects 1: (s: string)) +git-issue-2111.dfy(6,4): Error: wrong number of arguments (datatype constructor 'C' expects 1, got 0) 1 resolution/type errors detected in git-issue-2111.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2134.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2134.dfy.expect index 10edf10836f..3ab8c2f63cd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2134.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2134.dfy.expect @@ -6,14 +6,12 @@ git-issue-2134.dfy(22,12): Error: Cyclic dependency among declarations: P -> B - git-issue-2134.dfy(20,10): Error: base type of newtype 'B' is not fully determined; add an explicit type for bound variable 'b' git-issue-2134.dfy(27,8): Error: Cyclic dependency among declarations: X -> B -> X git-issue-2134.dfy(26,10): Error: base type of newtype 'B' is not fully determined; add an explicit type for bound variable 'b' -git-issue-2134.dfy(26,20): Error: arguments must have comparable types (got ?1 and ?0) git-issue-2134.dfy(32,11): Error: Cyclic dependency among declarations: X -> B -> X git-issue-2134.dfy(31,10): Error: Cyclic dependency among declarations: B -> B -> X git-issue-2134.dfy(41,12): Error: Cyclic dependency among declarations: P -> A -> B -> P git-issue-2134.dfy(48,12): Error: Cyclic dependency among declarations: P -> A -> Q -> B -> P git-issue-2134.dfy(55,12): Error: Cyclic dependency among declarations: P -> B -> P git-issue-2134.dfy(60,8): Error: Cyclic dependency among declarations: X -> B -> X -git-issue-2134.dfy(59,17): Error: arguments must have comparable types (got ?1 and ?0) git-issue-2134.dfy(65,11): Error: Cyclic dependency among declarations: X -> B -> X git-issue-2134.dfy(64,7): Error: Cyclic dependency among declarations: B -> B -> X -18 resolution/type errors detected in git-issue-2134.dfy +16 resolution/type errors detected in git-issue-2134.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2139.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2139.dfy.expect index 356acecd947..03c8153caf0 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2139.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2139.dfy.expect @@ -1,5 +1,6 @@ -git-issue-2139.dfy(16,11): Error: pattern doesn't correspond to a tuple -git-issue-2139.dfy(9,13): Error: Constant pattern used in place of datatype -git-issue-2139.dfy(9,16): Error: Constant pattern used in place of datatype +git-issue-2139.dfy(16,11): Error: string literal "B" used as if it had type (?12, ?13) +git-issue-2139.dfy(16,11): Error: string literal "B" used as if it had type (int, int) +git-issue-2139.dfy(9,13): Error: integer literal used as if it had type T +git-issue-2139.dfy(9,16): Error: integer literal used as if it had type T git-issue-2139.dfy(23,11): Warning: because of cyclic dependencies among constructor argument types, no instances of datatype 'T' can be constructed -3 resolution/type errors detected in git-issue-2139.dfy +4 resolution/type errors detected in git-issue-2139.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy index a0440b1654d..15f534b83a9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy @@ -1,16 +1,16 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" -// RUN: %diff "%s.expect" "%t" +// RUN: %testDafnyForEachResolver --expect-exit-code=2 "%s" + module Comparator { datatype Comparator = Comparator(int) } abstract module ADT { - import C : Comparator + import C: Comparator } abstract module CC { - import C : Comparator + import C: Comparator } abstract module IntADT { @@ -19,8 +19,8 @@ abstract module IntADT { method m() { - var cmp : CC.C.Comparator := CC.C.Comparator(0); - var cmp2 : ADT.C.Comparator := cmp; + var cmp: CC.C.Comparator := CC.C.Comparator(0); + var cmp2: ADT.C.Comparator := cmp; } } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.expect index 814626ee570..e15cf7ac985 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.expect @@ -1,2 +1,2 @@ -git-issue-216.dfy(23,32): Error: RHS (of type CC.C.Comparator) not assignable to LHS (of type ADT.C.Comparator) +git-issue-216.dfy(23,31): Error: RHS (of type CC.C.Comparator) not assignable to LHS (of type ADT.C.Comparator) 1 resolution/type errors detected in git-issue-216.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.refresh.expect new file mode 100644 index 00000000000..9f7b9e6ea5e --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-216.dfy.refresh.expect @@ -0,0 +1,2 @@ +git-issue-216.dfy(23,31): Error: RHS (of type Comparator) not assignable to LHS (of type Comparator) +1 resolution/type errors detected in git-issue-216.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2200.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2200.dfy.expect index e3d6e3e6091..d077fc28906 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2200.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2200.dfy.expect @@ -1,2 +1,2 @@ -git-issue-2200.dfy(6,21): Error: wrong number of arguments (got 2, but function 'f' expects 1: (i: int)) +git-issue-2200.dfy(6,21): Error: wrong number of arguments (function 'f' expects 1, got 2) 1 resolution/type errors detected in git-issue-2200.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-227.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-227.dfy.expect index 4fe73875e91..cb6efecf547 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-227.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-227.dfy.expect @@ -1,4 +1,4 @@ -git-issue-227.dfy(89,22): Error: all lines in a calculation must have the same type (got seq after AbstractMap.Variables) -git-issue-227.dfy(88,16): Error: arguments must have comparable types (got AbstractMap.Variables and seq) -git-issue-227.dfy(89,22): Error: arguments must have comparable types (got seq and AbstractMap.Variables) +git-issue-227.dfy(89,22): Error: all lines in a calculation must have the same type (got seq after Variables) +git-issue-227.dfy(88,16): Error: arguments must have comparable types (got Variables and seq) +git-issue-227.dfy(89,22): Error: arguments must have comparable types (got seq and Variables) 3 resolution/type errors detected in git-issue-227.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2429.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2429.dfy index 3a31316a610..b121dedbdb6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2429.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2429.dfy @@ -1,9 +1,9 @@ -// RUN: %verify --allow-axioms "%s" > "%t" +// RUN: %verify --allow-axioms --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" ghost predicate P(s: seq) -trait T { +trait T extends object { method M(a: A) requires Q([a][0 := a]) modifies if P([a][0 := a]) then {} else {this} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2477.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2477.dfy index 8226758b4e7..ee6fcef8a9a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2477.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2477.dfy @@ -1,7 +1,7 @@ // RUN: %exits-with 4 %baredafny verify --show-snippets:false --use-basename-for-filename --cores:2 --verification-time-limit:300 --resource-limit:5e6 "%s" > "%t" // RUN: %diff "%s.expect" "%t" -trait T { +trait T extends object { predicate P() reads {this} } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2500.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2500.dfy.refresh.expect new file mode 100644 index 00000000000..7fdbe544701 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2500.dfy.refresh.expect @@ -0,0 +1,5 @@ +git-issue-2500.dfy(21,12): Error: the function must provide an equal or more detailed postcondition than in its parent trait +git-issue-2500.dfy(24,12): Error: the function must provide an equal or more detailed postcondition than in its parent trait +git-issue-2500.dfy(37,12): Error: the function must provide an equal or more detailed postcondition than in its parent trait + +Dafny program verifier finished with 25 verified, 3 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy index 06f920d93a4..356737e2af1 100755 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy @@ -1,10 +1,10 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" -// RUN: %diff "%s.expect" "%t" +// RUN: %testDafnyForEachResolver --expect-exit-code=2 "%s" + module Class { class T { - static const a := 1 + b; // const definition contains a cycle: T.a -> T.b -> T.a - static const b := 2 + a; + static const a := 1 + b + static const b := 2 static ghost predicate F() decreases 0 { !L() } static least predicate L() { F() } @@ -24,8 +24,8 @@ module Class { module Datatype { datatype T = A { - static const a := 1 + b; // const definition contains a cycle: T.a -> T.b -> T.a - static const b := 2 + a; + static const a := 1 + b + static const b := 2 static ghost predicate F() decreases 0 { !L() } static least predicate L() { F() } @@ -45,8 +45,8 @@ module Datatype { module Newtype { newtype T = int { - static const a := 1 + b; // const definition contains a cycle: T.a -> T.b -> T.a - static const b := 2 + a; + static const a := 1 + b + static const b := 2 static ghost predicate F() decreases 0 { !L() } static least predicate L() { F() } @@ -66,8 +66,8 @@ module Newtype { module AbstractType { type T { - static const a := 1 + b; // const definition contains a cycle: T.a -> T.b -> T.a - static const b := 2 + a; + static const a := 1 + b + static const b := 2 static ghost predicate F() decreases 0 { !L() } static least predicate L() { F() } @@ -84,3 +84,22 @@ module AbstractType { method Oops2() ensures false { var _ := T.F(); } method Oops3() ensures false { var _ := T.Negative(); } } + +module Cycles { + class Class { + static const a := 1 + b // const definition contains a cycle: a -> b -> a + static const b := 2 + a + } + datatype Datatype = A { + static const a := 1 + b // const definition contains a cycle: a -> b -> a + static const b := 2 + a + } + newtype Newtype = int { + static const a := 1 + b // const definition contains a cycle: a -> b -> a + static const b := 2 + a + } + type AbstractType { + static const a := 1 + b // const definition contains a cycle: a -> b -> a + static const b := 2 + a + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.expect index 3c62971e838..3459ad88225 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.expect @@ -1,17 +1,17 @@ -git-issue-2506.dfy(6,17): Error: const definition contains a cycle: T.a -> T.b -> T.a git-issue-2506.dfy(10,34): Error: a recursive call from a least predicate can go only to other least predicates git-issue-2506.dfy(13,49): Error: a least predicate can be called recursively only in positive positions git-issue-2506.dfy(15,45): Error: a least predicate is not allowed to declare any ensures clause -git-issue-2506.dfy(27,17): Error: const definition contains a cycle: T.a -> T.b -> T.a git-issue-2506.dfy(31,34): Error: a recursive call from a least predicate can go only to other least predicates git-issue-2506.dfy(34,49): Error: a least predicate can be called recursively only in positive positions git-issue-2506.dfy(36,45): Error: a least predicate is not allowed to declare any ensures clause -git-issue-2506.dfy(48,17): Error: const definition contains a cycle: T.a -> T.b -> T.a git-issue-2506.dfy(52,34): Error: a recursive call from a least predicate can go only to other least predicates git-issue-2506.dfy(55,49): Error: a least predicate can be called recursively only in positive positions git-issue-2506.dfy(57,45): Error: a least predicate is not allowed to declare any ensures clause -git-issue-2506.dfy(69,17): Error: const definition contains a cycle: T.a -> T.b -> T.a git-issue-2506.dfy(73,34): Error: a recursive call from a least predicate can go only to other least predicates git-issue-2506.dfy(76,49): Error: a least predicate can be called recursively only in positive positions git-issue-2506.dfy(78,45): Error: a least predicate is not allowed to declare any ensures clause +git-issue-2506.dfy(90,17): Error: const definition contains a cycle: Class.a -> Class.b -> Class.a +git-issue-2506.dfy(94,17): Error: const definition contains a cycle: Datatype.a -> Datatype.b -> Datatype.a +git-issue-2506.dfy(98,17): Error: const definition contains a cycle: Newtype.a -> Newtype.b -> Newtype.a +git-issue-2506.dfy(102,17): Error: const definition contains a cycle: AbstractType.a -> AbstractType.b -> AbstractType.a 16 resolution/type errors detected in git-issue-2506.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.refresh.expect new file mode 100644 index 00000000000..20050008ca1 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2506.dfy.refresh.expect @@ -0,0 +1,17 @@ +git-issue-2506.dfy(10,34): Error: a recursive call from a least predicate can go only to other least predicates +git-issue-2506.dfy(13,49): Error: a least predicate can be called recursively only in positive positions +git-issue-2506.dfy(15,45): Error: a least predicate is not allowed to declare any ensures clause +git-issue-2506.dfy(31,34): Error: a recursive call from a least predicate can go only to other least predicates +git-issue-2506.dfy(34,49): Error: a least predicate can be called recursively only in positive positions +git-issue-2506.dfy(36,45): Error: a least predicate is not allowed to declare any ensures clause +git-issue-2506.dfy(52,34): Error: a recursive call from a least predicate can go only to other least predicates +git-issue-2506.dfy(55,49): Error: a least predicate can be called recursively only in positive positions +git-issue-2506.dfy(57,45): Error: a least predicate is not allowed to declare any ensures clause +git-issue-2506.dfy(73,34): Error: a recursive call from a least predicate can go only to other least predicates +git-issue-2506.dfy(76,49): Error: a least predicate can be called recursively only in positive positions +git-issue-2506.dfy(78,45): Error: a least predicate is not allowed to declare any ensures clause +git-issue-2506.dfy(90,17): Error: Cyclic dependency among declarations: Class.a -> Class.b -> Class.a +git-issue-2506.dfy(94,17): Error: Cyclic dependency among declarations: Datatype.a -> Datatype.b -> Datatype.a +git-issue-2506.dfy(98,17): Error: Cyclic dependency among declarations: Newtype.a -> Newtype.b -> Newtype.a +git-issue-2506.dfy(102,17): Error: Cyclic dependency among declarations: AbstractType.a -> AbstractType.b -> AbstractType.a +16 resolution/type errors detected in git-issue-2506.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672-legacy.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672-legacy.dfy new file mode 100644 index 00000000000..956ddd5054e --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672-legacy.dfy @@ -0,0 +1,38 @@ +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false + +newtype sreal = r: real | r > -4 as real +newtype sint = r: int | r > -4 as int +newtype ssreal = r: sreal | r > -3 as sreal +newtype ssint = r: sint | r > -3 as sint + +method Print(b: bool, end: string) + // Print boolean `b` as `true` or `false`, then print `end`. This is needed + // by C++ due to BUG(https://github.com/dafny-lang/dafny/issues/2773). +{ + if b { + print "true"; + } else { + print "false"; + } + print end; +} + +method Main() { + Print(24 as sreal <= 1507 as sreal, " "); + Print(24 as ssreal <= 1507 as ssreal, "\n"); + + Print(24 as sreal == 1507 as sreal, " "); + Print(24 as ssreal == 1507 as ssreal, "\n"); + + Print(24 as sreal >= 1507 as sreal, " "); + Print(24 as ssreal >= 1507 as ssreal, "\n"); + + Print(24 as sreal < 1507 as sreal, " "); + Print(24 as ssreal < 1507 as ssreal, "\n"); + + Print(24 as sreal != 1507 as sreal, " "); + Print(24 as ssreal != 1507 as ssreal, "\n"); + + Print(24 as sreal > 1507 as sreal, " "); + Print(24 as ssreal > 1507 as ssreal, "\n"); +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672-legacy.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672-legacy.dfy.expect new file mode 100644 index 00000000000..41209db46ab --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672-legacy.dfy.expect @@ -0,0 +1,6 @@ +true true +false false +false false +true true +true true +false false diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672.dfy index b5a789937ae..599ee118b55 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2672.dfy @@ -1,8 +1,8 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler "%s" newtype sreal = r: real | r > -4 as real newtype sint = r: int | r > -4 as int -newtype ssreal = r: sreal | r > -3 as sreal +newtype ssreal = r: sreal | r > -3 as real as sreal newtype ssint = r: sint | r > -3 as sint method Print(b: bool, end: string) @@ -19,8 +19,8 @@ method Print(b: bool, end: string) method Main() { Print(24 as real <= 1507 as real, " "); - Print(24 as sreal <= 1507 as sreal, " "); - Print(24 as ssreal <= 1507 as ssreal, " "); + Print(24 as real as sreal <= 1507 as real as sreal, " "); + Print(24 as real as ssreal <= 1507 as real as ssreal, " "); Print(24 as int <= 1507 as int, " "); Print(24 as sint <= 1507 as sint, " "); Print(24 as ssint <= 1507 as ssint, " "); @@ -30,8 +30,8 @@ method Main() { Print(24 as ORDINAL <= 1507 as ORDINAL, "\n"); Print(24 as real == 1507 as real, " "); - Print(24 as sreal == 1507 as sreal, " "); - Print(24 as ssreal == 1507 as ssreal, " "); + Print(24 as real as sreal == 1507 as real as sreal, " "); + Print(24 as real as ssreal == 1507 as real as ssreal, " "); Print(24 as int == 1507 as int, " "); Print(24 as sint == 1507 as sint, " "); Print(24 as ssint == 1507 as ssint, " "); @@ -41,8 +41,8 @@ method Main() { Print(24 as ORDINAL == 1507 as ORDINAL, "\n"); Print(24 as real >= 1507 as real, " "); - Print(24 as sreal >= 1507 as sreal, " "); - Print(24 as ssreal >= 1507 as ssreal, " "); + Print(24 as real as sreal >= 1507 as real as sreal, " "); + Print(24 as real as ssreal >= 1507 as real as ssreal, " "); Print(24 as int >= 1507 as int, " "); Print(24 as sint >= 1507 as sint, " "); Print(24 as ssint >= 1507 as ssint, " "); @@ -52,8 +52,8 @@ method Main() { Print(24 as ORDINAL >= 1507 as ORDINAL, "\n"); Print(24 as real < 1507 as real, " "); - Print(24 as sreal < 1507 as sreal, " "); - Print(24 as ssreal < 1507 as ssreal, " "); + Print(24 as real as sreal < 1507 as real as sreal, " "); + Print(24 as real as ssreal < 1507 as real as ssreal, " "); Print(24 as int < 1507 as int, " "); Print(24 as sint < 1507 as sint, " "); Print(24 as ssint < 1507 as ssint, " "); @@ -63,8 +63,8 @@ method Main() { Print(24 as ORDINAL < 1507 as ORDINAL, "\n"); Print(24 as real != 1507 as real, " "); - Print(24 as sreal != 1507 as sreal, " "); - Print(24 as ssreal != 1507 as ssreal, " "); + Print(24 as real as sreal != 1507 as real as sreal, " "); + Print(24 as real as ssreal != 1507 as real as ssreal, " "); Print(24 as int != 1507 as int, " "); Print(24 as sint != 1507 as sint, " "); Print(24 as ssint != 1507 as ssint, " "); @@ -74,8 +74,8 @@ method Main() { Print(24 as ORDINAL != 1507 as ORDINAL, "\n"); Print(24 as real > 1507 as real, " "); - Print(24 as sreal > 1507 as sreal, " "); - Print(24 as ssreal > 1507 as ssreal, " "); + Print(24 as real as sreal > 1507 as real as sreal, " "); + Print(24 as real as ssreal > 1507 as real as ssreal, " "); Print(24 as int > 1507 as int, " "); Print(24 as sint > 1507 as sint, " "); Print(24 as ssint > 1507 as ssint, " "); diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2693.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2693.dfy.expect index 03944411c2d..068da5541d5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2693.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2693.dfy.expect @@ -1,5 +1,5 @@ -git-issue-2693.dfy(10,10): Warning: Support for member 'PropagateFailure' in type 'EvenGood_OddBad?' (used indirectly via a :- statement) being a method is deprecated; declare it to be a function instead -git-issue-2693.dfy(10,10): Warning: Support for member 'Extract' in type 'EvenGood_OddBad?' (used indirectly via a :- statement) being a method is deprecated; declare it to be a function instead +git-issue-2693.dfy(10,10): Warning: Support for member 'PropagateFailure' in type 'EvenGood_OddBad' (used indirectly via a :- statement) being a method is deprecated; declare it to be a function instead +git-issue-2693.dfy(10,10): Warning: Support for member 'Extract' in type 'EvenGood_OddBad' (used indirectly via a :- statement) being a method is deprecated; declare it to be a function instead git-issue-2693.dfy(10,10): Error: a postcondition could not be proved on this return path git-issue-2693.dfy(6,46): Related location: this is the postcondition that could not be proved git-issue-2693.dfy(21,12): Related location: this proposition could not be proved diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-274.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-274.dfy index abe0dc6cec2..8f5edc00f3b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-274.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-274.dfy @@ -7,8 +7,7 @@ module P { module N2 { import opened M = P - trait T { - var m: M.M + trait T extends object { + var m: M.M } } - diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2748.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2748.dfy index b99864ba3ea..d0360a0fdc3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2748.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2748.dfy @@ -1,4 +1,4 @@ -// RUN: %verify "%s" > "%t" +// RUN: %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" function f(x: int): int { 10 - x * x } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy index 2d076023f54..09dfe617308 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy @@ -6,15 +6,15 @@ module Main { newtype b2 = x | 0 <= x < 3%(2-2) newtype b3 = x | 0 <= x < (3.0/(2.0-2.0)) as int newtype b4 = x | 0 <= x < 1.5 as int - newtype b5 = x | 0 <= x < 1000.0 as bv8 as int - newtype b6 = x | 0 <= x < 100.5 as bv8 as int + newtype b5 = x | 0 <= x < 1000.0 as int as bv8 as int + newtype b6 = x | 0 <= x < 100.5 as int as bv8 as int newtype b8 = x | 0 <= x < 1000 as bv8 as int newtype b9 = x | 0 <= x < 1000 as bv16 as bv8 as int newtype b10 = x | 0 <= x < -1 as int as char as int - newtype b11 = x | 0 <= x < -1 as real as char as int - newtype b12 = x | 0 <= x < 1.5 as real as char as int - newtype b13 = x | 0 <= x < 'c' as bv2 as int - newtype b14 = x | 0 <= x < 0xffffff as bv32 as char as int + newtype b11 = x | 0 <= x < -1 as real as int as char as int + newtype b12 = x | 0 <= x < 1.5 as real as int as char as int + newtype b13 = x | 0 <= x < 'c' as int as bv2 as int + newtype b14 = x | 0 <= x < 0xffffff as bv32 as int as char as int newtype b15 = x | 0 <= x < ((10 as bv8)/(0 as bv8)) as int newtype b16 = x | 0 <= x < ((10 as bv8)%(0 as bv8)) as int newtype b17 = x | 0 <= x < (10 as bv8 << -1) as int diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy.expect index 94c26df0806..46dd2f1a834 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276a.dfy.expect @@ -23,7 +23,7 @@ git-issue-276a.dfy(7,10): Error: cannot find witness that shows type is inhabite git-issue-276a.dfy(7,26): Related location: this proposition could not be proved git-issue-276a.dfy(7,32): Error: possible division by zero git-issue-276a.dfy(8,32): Error: the real-based number must be an integer (if you want truncation, apply .Floor to the real-based number) -git-issue-276a.dfy(9,35): Error: value to be converted might not fit in bv8 +git-issue-276a.dfy(9,42): Error: value to be converted might not fit in bv8 git-issue-276a.dfy(10,34): Error: the real-based number must be an integer (if you want truncation, apply .Floor to the real-based number) git-issue-276a.dfy(11,33): Error: value to be converted might not fit in bv8 git-issue-276a.dfy(12,41): Error: value to be converted might not fit in bv8 @@ -32,12 +32,12 @@ git-issue-276a.dfy(13,27): Related location: this proposition could not be prove git-issue-276a.dfy(13,39): Error: value to be converted might not fit in char git-issue-276a.dfy(14,10): Error: cannot find witness that shows type is inhabited (only tried 0); try giving a hint through a 'witness' or 'ghost witness' clause, or use 'witness *' to treat as a possibly empty type git-issue-276a.dfy(14,27): Related location: this proposition could not be proved -git-issue-276a.dfy(14,40): Error: real value to be converted might not fit in char +git-issue-276a.dfy(14,47): Error: value to be converted might not fit in char git-issue-276a.dfy(15,41): Error: the real-based number must be an integer (if you want truncation, apply .Floor to the real-based number) -git-issue-276a.dfy(16,33): Error: value to be converted might not fit in bv2 +git-issue-276a.dfy(16,40): Error: value to be converted might not fit in bv2 git-issue-276a.dfy(17,10): Error: cannot find witness that shows type is inhabited (only tried 0); try giving a hint through a 'witness' or 'ghost witness' clause, or use 'witness *' to treat as a possibly empty type git-issue-276a.dfy(17,27): Related location: this proposition could not be proved -git-issue-276a.dfy(17,46): Error: bit-vector value to be converted might not fit in char +git-issue-276a.dfy(17,53): Error: value to be converted might not fit in char git-issue-276a.dfy(18,41): Error: possible division by zero git-issue-276a.dfy(19,41): Error: possible division by zero git-issue-276a.dfy(20,10): Error: cannot find witness that shows type is inhabited (only tried 0); try giving a hint through a 'witness' or 'ghost witness' clause, or use 'witness *' to treat as a possibly empty type diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276c.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276c.dfy index 2aceb330ce0..d7cd5726aaf 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276c.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276c.dfy @@ -7,9 +7,9 @@ module Main { const c := s[4] newtype b0 = x | 0 <= x < |s+s| newtype b1 = x | 0 <= x < c as int - newtype b2 = x | 0 <= x < c as bv8 as int + newtype b2 = x | 0 <= x < c as int as bv8 as int newtype b3 = x | 0 <= x < 20 as char as int - newtype b4 = x | 0 <= x < 200 as bv8 as char as int + newtype b4 = x | 0 <= x < 200 as bv8 as int as char as int newtype b5 = x | 0 <= x < ( if 'a' == c then 30 else 40 ) newtype b6 = x | 0 <= x < ( if 'a' != c then 30 else 40 ) newtype b7 = x | 0 <= x < ( if 'a' <= c then 30 else 40 ) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276r.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276r.dfy index 50ee627c41c..d3bd711da8c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276r.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-276r.dfy @@ -1,4 +1,4 @@ -// RUN: %verify --show-hints "%s" > "%t" +// RUN: %verify --show-hints --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // Testing constant folding of real operations diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy index 95d47dfe139..38ba1985b05 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy @@ -1,6 +1,6 @@ -// RUN: %exits-with 2 %dafny /compile:3 /optimize "%s" > "%t" +// RUN: %exits-with 2 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" -method m(a : array) { - assert a[..true] == a[..true]; +method M(a: array) { + assert a[..true] == a[true..]; // error (x2): incorrect type } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy.expect index 3c3d0792827..2036ddd0b23 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-277.dfy.expect @@ -1,6 +1,3 @@ -Warning: this way of using the CLI is deprecated. Use 'dafny --help' to see help for the new Dafny CLI format -git-issue-277.dfy(5,12): Error: wrong number of indices for multi-selection -git-issue-277.dfy(5,25): Error: wrong number of indices for multi-selection -git-issue-277.dfy(5,12): Error: incorrect type for selection into array (got bool) -git-issue-277.dfy(5,25): Error: incorrect type for selection into array (got bool) -4 resolution/type errors detected in git-issue-277.dfy +git-issue-277.dfy(5,12): Error: multi-element selection expression must have an integer or bitvector type (got bool) +git-issue-277.dfy(5,23): Error: multi-element selection expression must have an integer or bitvector type (got bool) +2 resolution/type errors detected in git-issue-277.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2828.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2828.dfy.expect index 29737141261..7025d2dc2cd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2828.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2828.dfy.expect @@ -1,4 +1,2 @@ git-issue-2828.dfy(6,9): Error: unresolved identifier: arr -git-issue-2828.dfy(6,13): Error: incorrect type for selection into ? (got int) -git-issue-2828.dfy(6,12): Error: sequence has type ? which is incompatible with expected type bool -3 resolution/type errors detected in git-issue-2828.dfy +1 resolution/type errors detected in git-issue-2828.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy index 3d624e30c15..aa10e2d0219 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy @@ -52,6 +52,6 @@ ghost function RepeatAux(pred : (string, A) -> bool, repr: iset, input: st || (exists init, tail, a, alist | a in repr :: && input == init + tail && output == [a] + alist - && pred(a, init) + && pred(a, init) // error (x2): parameters are reversed, so the types ("A" and "string") are reversed && RepeatAux(pred, repr, tail, alist)) } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy.expect index c3f63c571f5..895cd333fe6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-2829.dfy.expect @@ -1,7 +1,5 @@ -git-issue-2829.dfy(52,38): Error: second argument to "in" must be a set, multiset, or sequence with elements of type string, or a map with domain string (instead got iset) (expecting element type to be assignable to A (got string)) -git-issue-2829.dfy(53,23): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like or map-like type (instead got A) -git-issue-2829.dfy(53,15): Error: arguments must have comparable types (got string and A) -git-issue-2829.dfy(54,16): Error: arguments must have comparable types (got seq and seq) -git-issue-2829.dfy(56,31): Error: incorrect argument type at index 2 for function parameter 'input' (expected string, found A) -git-issue-2829.dfy(56,37): Error: incorrect argument type at index 3 for function parameter 'output' (expected seq, found seq) (covariant type parameter would require string <: A) -6 resolution/type errors detected in git-issue-2829.dfy +git-issue-2829.dfy(55,14): Error: incorrect argument type at index 0 for function application parameter (expected string, found A) +git-issue-2829.dfy(55,17): Error: incorrect argument type at index 1 for function application parameter (expected A, found string) +git-issue-2829.dfy(55,14): Error: type mismatch for argument 0 (function expects string, got A) +git-issue-2829.dfy(55,17): Error: type mismatch for argument 1 (function expects A, got string) +4 resolution/type errors detected in git-issue-2829.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283.dfy index 1ca6d48d32c..44defa0fa84 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283.dfy @@ -51,7 +51,7 @@ trait Foo var x: int := 0; match r { case Success(C1()) => x := 1; - case Success(C2(x)) => x := 2; // x is local variable + case Success(C2(xx)) => var y := xx; case Failure(e) => x := 3; } assert x == 0 || x == 1 || x == 3; @@ -68,7 +68,7 @@ trait Foo var x: real := 0.0; match r { case Success(C1()) => x := 1.0; - case Success(C2(x)) => x := 2; // x is local variable + case Success(C2(xx)) => var y := xx; case Failure(e) => x := 3.0; } assert x == 0.0 || x == 1.0 || x == 3.0; @@ -94,13 +94,13 @@ trait Foo method FooMethod4(r: Result) ensures match r { - case Success(C2) => true // OK -- C2 is a variable + case Success(C2x) => true case Failure(e) => true } { var x: int := 0; match r { - case Success(C2) => x := 1; + case Success(C2x) => x := 1; case Failure(e) => x := 2; } assert x > 0; diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy index 1aa3ed63e8e..e2bf05c6026 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy @@ -34,8 +34,108 @@ trait Foo ensures match r { case Success(C1()) => true - case Success(C1) => true // ERROR - duplicate constructor, not shown because this warning is created post resolution. + case Success(C1) => true // this is the same as the previous case (warning is not shown, because it is emitted post resolution) case Failure(e) => true } -} + method FooMethod2q(r: Result) + ensures + match r { + case Success(C1()) => true // OK + case Success(C2(x)) => true // OK + case Failure(e) => true + } + { + var x: int := 0; + match r { + case Success(C1()) => x := 1; + case Success(C2(x)) => x := 2; // error: x is not local variable + case Failure(e) => x := 3; + } + assert x == 0 || x == 1 || x == 3; + expect x == 0 || x == 1 || x == 3; + } + + method FooMethod2r(r: Result) + ensures + match r { + case Success(C1()) => true // OK + case Success(C2(x)) => true // OK + case Failure(e) => true + } + { + var x: real := 0.0; + match r { + case Success(C1()) => x := 1.0; + case Success(C2(x)) => x := 2; // error: x is not local variable + case Failure(e) => x := 3.0; + } + assert x == 0.0 || x == 1.0 || x == 3.0; + expect x == 0.0 || x == 1.0 || x == 3.0; + } + + method FooMethod40(r: Result) + ensures + match r { + case Success(C2) => true // error: unary constructor applied without arguments + case Failure(e) => true + } + { + var x: int := 0; + match r { + case Success(C2) => x := 1; // error: unary constructor applied without arguments + case Failure(e) => x := 2; + } + assert x > 0; + expect x == 1; + } + + method FooMethod41(r: Result) + ensures + match r { + case Success(C1) => true // OK -- C1 is a nullary constructor + case Failure(e) => true + } + { + var x: int := 0; + match r { + case Success(C1) => x := 1; // OK -- C1 is a nullary constructor + case Failure(e) => x := 2; + } + assert x > 0; + expect x == 1; + } + + method FooMethod42(r: Result) + ensures + match r { + case Success(C1()) => true // OK -- C1 is a nullary constructor + case Failure(e) => true + } + { + var x: int := 0; + match r { + case Success(C1()) => x := 1; // OK -- C1 is a nullary constructor + case Failure(e) => x := 2; + } + assert x > 0; + expect x == 1; + } + + method FooMethod50(r: Result) + ensures + match r { + case Success(C1) => true // OK -- C1 is a bound variable (since the type expected here is string) + case Failure(e) => true + } + { + var x: int := 0; + match r { + case Success(C1) => x := 1; // OK -- C1 is a bound variable (since the type expected here is string) + case Failure(e) => x := 2; + } + assert x > 0; + expect x == 1; + } + +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy.expect index 8c5eadab2f8..4ebef937fbe 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283a.dfy.expect @@ -1,4 +1,8 @@ -git-issue-283a.dfy(15,21): Error: tuple type does not match type string -git-issue-283a.dfy(22,21): Error: member D does not exist in type C -git-issue-283a.dfy(29,21): Error: constructor C2 of arity 1 is applied to 0 argument(s) -3 resolution/type errors detected in git-issue-283a.dfy +git-issue-283a.dfy(15,21): Error: tuple type does not match type 'string' +git-issue-283a.dfy(22,21): Error: type 'C' does not contain a datatype constructor 'D' +git-issue-283a.dfy(29,21): Error: constructor 'C2' of arity 1 is applied to 0 argument(s) +git-issue-283a.dfy(52,29): Error: LHS of assignment must denote a mutable variable +git-issue-283a.dfy(70,29): Error: LHS of assignment must denote a mutable variable +git-issue-283a.dfy(80,21): Error: constructor 'C2' of arity 1 is applied without any arguments +git-issue-283a.dfy(86,19): Error: constructor 'C2' of arity 1 is applied without any arguments +7 resolution/type errors detected in git-issue-283a.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy index 49222e1942b..2095616ebf9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy @@ -1,53 +1,133 @@ // RUN: %exits-with 2 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" -datatype Result = - | Success(value: T) - | Failure(error: string) +module Main { + datatype Result = + | Success(value: T) + | Failure(error: string) -datatype Bar = C1() | C2(bl: string) + datatype Bar = C1() | C2(bl: string) -const X: int := 42 -const SS: string := "asd" + const X: int := 42 + const SS: string := "asd" -trait Foo -{ - static const S: string := "asd" + trait Foo + { + static const S: string := "asd" - method FooMethod1() returns (r: Result) - ensures - match Result.Failure(S) { - case Failure(X) => true // ERROR: X is a constant, but wrong type - case Success(C1) => true // C1 is a variable - } + method FooMethod1() returns (r: Result) + ensures + match Result.Failure(S) { + case Failure(X) => true // ERROR: X is a constant, but wrong type + case Success(C1) => true // C1 is a variable + } -} + } -datatype Cell = Cell(value: T) + datatype Cell = Cell(value: T) -const Y := 1 // type of Y must be inferred -method q() { - var c: Cell; // note, type argument omitted; it will eventually be inferred - match c { - case Cell(Y) => - case Cell(_) => // if Y is a const, then this case is not redundant + const Y := 1 // type of Y must be inferred + method q() { + var c: Cell; // note, type argument omitted; it will eventually be inferred + match c { + case Cell(Y) => + case Cell(_) => // if Y is a const, then this case is not redundant + } + c := Cell(1.2); // ERROR: 1.2 is real, which doesn't agree with the inferred type Cell of c } - c := Cell(1.2); // ERROR: 1.2 is real, which doesn't agree with the inferred type Cell of c -} -method qq() { - var c: Cell; - match c { - case Cell(Y) => // ERROR: Y is a const int, so a type mismatch is reported - case Cell(_) => // if Y is a const, then this case is not redundant + method qq() { + var c: Cell; + match c { + case Cell(Y) => // ERROR: Y is a const int, so a type mismatch is reported + case Cell(_) => // if Y is a const, then this case is not redundant + } } -} -method qqq() { - var c: Cell; - match c { - case Cell(XX) => // XX is a variable - case Cell(_) => // redundant case warning not show because it's created post resolution + method qqq() { + var c: Cell; + match c { + case Cell(XX: int) => // XX is a variable (there's a subtle point here, see SubtlePoint module below) + case Cell(_) => // redundant case warning not shown because it's created post resolution + } } } +module SubtlePoint { + // Methods Example0 and Example1 below differ only in where the assignment "c := Cell(Another);" takes place. + // + // In Example0, the assignment is placed before the "match". So, by the time the resolver looks at the "match", + // it knows the type of "c" is "Cell". This lets the resolver look up "One" in type "Way" and can then + // determine that "One" denotes a constructor. (And in Example2, that lookup finds that "one" is not a + // constructor.) + // + // In Example1, the resolver looks at the "match" before it knows enough of the type of + // "c" to determine a type for the argument in "case Cell(...)". Thus, the resolver does not know + // (at the time it's looking at the "match") if the argument is a variable or a literal. + // The resolver thus reports an error, complaining that it doesn't know enough about the type + // of "c" when looking at the "match". + // + // A variation of Example1 is Example3 (and also method qqq above), where the argument is given as an explicit + // type. That says that the argument to the Cell constructor is to be a variable. + // + // Yet another variation of Example1 is Example4, where the argument in the pattern is "_". That also makes it + // clear that the programs wants a(n anonymous) variable, so no error is reported. + // + // Reflection: These subtleties stem from the old design in Dafny of using the enclosing type when looking up + // resolving pieces of case patterns. It would be good to change this design so that each piece of a pattern + // could be resolved without needing to know the enclosing type. When that change eventually makes it into the + // language, then the outcome of these tests will change. + // + // Note: The legacy resolver treats "One" as a variable in both Example0 and Example2. That looks good at first, + // because it means the type argument of the type of "c" is not needed. However, if the type of "c" is + // explicitly given as "Cell", then the legacy resolver treat "One" as a constructor. That seems worse. + // The new resolver at least behaves consistently (for programs that do pass the resolver), regardless of when + // or how the full type information of "c" is obtained. + // + // A future improvement of the resolver would be to delay looking at the "match" until enough type information + // has been inferred. This would mean that Example1 would no longer give an error, but would behave just like + // Example0. + + datatype Cell = Cell(value: T) + datatype Way = One | Another + + method Example0() { + var c: Cell; + c := Cell(Another); + match c { // fine, the type of "c" is known, so the "One" on the next line is known to denote the Way.One constructor + case Cell(One) => + } + } + + method Example1() { + var c: Cell; + match c { // error: type of c is not sufficiently resolved by this time + case Cell(One) => + } + c := Cell(Another); + } + + method Example2() { + var c: Cell; + c := Cell(Another); + match c { // fine, the type of "c" is known, so the "one" on the next line is known not to denote any Way constructor + case Cell(one) => + } + } + + method Example3() { + var c: Cell; + match c { // fine, because the explicit type annotation ": Way" on the next line says that "One" is to be a variable + case Cell(One: Way) => + } + c := Cell(Another); + } + + method Example4() { + var c: Cell; + match c { // no error, since the type argument of "Cell" is not needed in "case Cell(_)" + case Cell(_) => + } + c := Cell(Another); + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy.expect index 4d1dcc3e8d6..65926151823 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-283g.dfy.expect @@ -1,4 +1,5 @@ -git-issue-283g.dfy(32,14): Error: the type of the pattern (int) does not agree with the match expression (real) -git-issue-283g.dfy(41,14): Error: the type of the pattern (int) does not agree with the match expression (real) -git-issue-283g.dfy(20,21): Error: the type of the pattern (int) does not agree with the match expression (string) -3 resolution/type errors detected in git-issue-283g.dfy +git-issue-283g.dfy(36,14): Error: real literal used as if it had type int +git-issue-283g.dfy(42,16): Error: literal pattern (of type int) cannot be used with source type real +git-issue-283g.dfy(21,23): Error: literal pattern (of type int) cannot be used with source type string +git-issue-283g.dfy(104,10): Error: Could not resolve the type of the source of the match expression. Please provide additional typing annotations. +4 resolution/type errors detected in git-issue-283g.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3125.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3125.dfy index 4007b04682c..76aa77ccf54 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3125.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3125.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method Foo() returns (i: int) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-314.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-314.dfy index a7fc06564a5..9396f16cb31 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-314.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-314.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false --relax-definite-assignment datatype S = S(G: array) datatype T = T(F: array, ghost Repr: set) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3294.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3294.dfy.expect index 75ade2bda83..801cb95496e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3294.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3294.dfy.expect @@ -1,3 +1,3 @@ CLI: Warning: The file 'git-issue-3294.dfy' was passed to --library. Verification for that file might have used options incompatible with the current ones, or might have been skipped entirely. Use a .doo file to enable Dafny to check that compatible options were used -git-issue-3294.dfy(7,4): Error: member IsFailure does not exist in FailureRestrictedType, in :- statement +git-issue-3294.dfy(7,4): Error: member IsFailure does not exist in FailureRestrictedType, in :- statement 1 resolution/type errors detected in git-issue-3294.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3304.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3304.dfy index b929b3827af..f063a344180 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3304.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3304.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename --show-snippets "%s" > "%t" +// RUN: %exits-with 2 %baredafny resolve --use-basename-for-filename --show-snippets --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method M() { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-343.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-343.dfy index e3d046857a0..3445747955f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-343.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-343.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method f(a: seq) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356-errors.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356-errors.dfy index fb4fc733b92..999ed958c8f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356-errors.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356-errors.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --allow-deprecation --unicode-char false "%s" > "%t" +// RUN: %exits-with 4 %verify --allow-deprecation --unicode-char false --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356.dfy index df4fa854cd9..051ea9b6fce 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-356.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment --allow-deprecation --unicode-char false +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --type-system-refresh=false --general-newtypes=false --relax-definite-assignment --allow-deprecation --unicode-char false module M { type Tx = i: int | 0 <= i <= 100 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804.dfy index f1ff9b690f0..7b70be09405 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" predicate P(x: int) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804a.dfy index 6cd132bf833..fea4cc2036d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804a.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" predicate P(x: int) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804b.dfy index 1ccf8357a3b..e2670a2efff 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804b.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" function RevealInFunctionNotMethodOk(i: int): (r: int) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804c.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804c.dfy index cbf89f9392c..a0ca3279cb7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804c.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804c.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" predicate P(i: int) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804d.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804d.dfy index 279ba2c14d0..455163ebbdd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804d.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3804d.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" predicate P(i: int) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3855.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3855.dfy index 827318ba2a7..ceaa025daa3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3855.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3855.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %baredafny verify --show-snippets:false --allow-axioms --allow-deprecation --use-basename-for-filename "%s" > "%t".raw +// RUN: %exits-with 4 %baredafny verify --show-snippets:false --allow-axioms --allow-deprecation --use-basename-for-filename --type-system-refresh=false --general-newtypes=false "%s" > "%t".raw // RUN: %sed 's/after [0-9]+ seconds/after seconds/' %t.raw > "%t" // RUN: %diff "%s.expect" "%t" // Nearly verbatim copy of the text case given in the issue diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3921.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3921.dfy index fad4fe6c052..3dbd8558c44 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3921.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3921.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module A { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3922.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3922.dfy index abf30d9c57c..a4916a30312 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3922.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3922.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module A { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4035.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4035.dfy index 35a8f87dcad..806889fde4c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4035.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4035.dfy @@ -4,7 +4,7 @@ module ConstInTrait { type ReallyEmpty = x: int | false witness * - trait UnimplementableTrait { + trait UnimplementableTrait extends object { const x: ReallyEmpty } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4056.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4056.dfy index e361696a68f..17b186709f6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4056.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4056.dfy @@ -1,7 +1,7 @@ // RUN: %verify %s > %t // RUN: %diff "%s.expect" "%t" -trait ADT { +trait ADT extends object { ghost function ReprFamily(n: nat): set decreases n ensures n > 0 ==> ReprFamily(n) >= ReprFamily(n-1) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4152.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4152.dfy index 64abeb6ed48..44cc4dca14a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4152.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4152.dfy @@ -1,5 +1,5 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" - +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --general-newtypes=false +// This file tests legacy conversions. In the new resolver, these require explicit casts. method Main() { var a: bv8 := 0xFF; var b: bv16 := 0xFFFF; diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4224.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4224.dfy index 2132a6c4cd3..163b2df48f5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4224.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4224.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Library { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4394.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4394.dfy index a1ed5df7c1f..0a87a4bff86 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4394.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4394.dfy @@ -1,4 +1,4 @@ -// RUN: %verify "%s" > "%t" +// RUN: %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype T = T( diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4471/git-issue-4471a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4471/git-issue-4471a.dfy index 55d98898494..673aa57d4a6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4471/git-issue-4471a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4471/git-issue-4471a.dfy @@ -1,8 +1,8 @@ // RUN: %exits-with 0 %verify "%s" -trait YT { +trait YT extends object { const f: W } class Y extends YT nat> { -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-484.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-484.dfy index 240bb45bd07..31fb769f194 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-484.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-484.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype MyInt = int diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-532.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-532.dfy index 0219c718379..5a60c7be1d5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-532.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-532.dfy @@ -2,7 +2,7 @@ predicate SuppressNoTriggerWarning(x: X) { true } -trait Tr { +trait Tr extends object { var x: int } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy index 52ae2d329a5..1b8e90f6977 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false --general-traits=legacy // Note, these tests seem to be specific to the old type system. With the new type system, // assignments that, in some way, involve a conversion from Number to Integer require an diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-6014.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-6014.dfy index b43e78bfeb9..4fbf97fc9c3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-6014.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-6014.dfy @@ -38,7 +38,7 @@ module UsingEnclosing { module A { - trait T { + trait T extends object { var a: X } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-611.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-611.dfy index e1a2dabc046..f344220a378 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-611.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-611.dfy @@ -1,4 +1,4 @@ -// RUN: %verify "%s" > "%t" +// RUN: %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module M1 { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-623.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-623.dfy index 9c3bd0b924d..9d54408d769 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-623.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-623.dfy @@ -1,6 +1,6 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false --general-traits=legacy "%s" > "%t" // RUN: %diff "%s.expect" "%t" - +// NOTE: This test fails with the new resolver and general traits, because of how it infers types in the Library modules. This should be fixed. // ----- example reported in Issue 623 module M1 { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-666.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-666.dfy index e438b0765f1..bc3230a7c61 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-666.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-666.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false --general-traits=legacy "%s" > "%t" // RUN: %diff "%s.expect" "%t" trait O { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-668.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-668.dfy index a82ea9fce6f..1732aa159e9 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-668.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-668.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" class X { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-686a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-686a.dfy index d58441223ff..33a65058966 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-686a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-686a.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype Color = Blue | Red diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-697e.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-697e.dfy index 310851abf9a..5812ec764e0 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-697e.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-697e.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false --relax-definite-assignment datatype Cell = Cell(x: int) type EvenCell = c: Cell | c.x % 2 == 0 witness Cell(0) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-701.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-701.dfy index e0c98905d10..995db780f17 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-701.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-701.dfy @@ -9,7 +9,7 @@ method Main() { print cc.y, " ", cc.k, " ", cc.l, "\n"; } -trait Trait { +trait Trait extends object { const y: Y const k: Y := y const l: Y diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731.dfy index 7a82ea5456b..7a90dc975e6 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731.dfy @@ -1,6 +1,6 @@ // RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment -trait Trait { +trait Trait extends object { const y: Y const k: Y := y const l: Y diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731b.dfy index 5d657eaf6ad..dc012b59c52 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-731b.dfy @@ -2,7 +2,7 @@ // Testing issue#731 when the class in question has type parameters -trait Tr2 { +trait Tr2 extends object { const w: W const y: Y } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-750.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-750.dfy index ecedfe8795d..c0056f9c10b 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-750.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-750.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method m() { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-779.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-779.dfy index 02ee491f4c4..041f66fed88 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-779.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-779.dfy @@ -1,4 +1,4 @@ -// RUN: %verify --relax-definite-assignment "%s" > "%t" +// RUN: %verify --relax-definite-assignment --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // Lines marked PRE-FIX were problems before this bug was fixed diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817.dfy index 006c718d256..d32c687ffca 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false datatype Result = Failure(msg: string) | Success(value: T) { predicate IsFailure() { Failure? } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817a.dfy index 16617082959..29d6fd4950f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817a.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler "%s" +// RUN: %testDafnyForEachCompiler "%s" -- --type-system-refresh=false --general-newtypes=false datatype Result = Failure(msg: string) | Success(value: T) { predicate IsFailure() { Failure? } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817b.dfy index bca56b10d4e..27a3dd77781 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817b.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --relax-definite-assignment "%s" > "%t" +// RUN: %exits-with 4 %verify --relax-definite-assignment --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype Result = Failure(msg: string) | Success(value: T) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817c.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817c.dfy index 2e6aeec1915..f80c5c2f444 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817c.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817c.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --relax-definite-assignment --allow-deprecation "%s" > "%t" +// RUN: %exits-with 4 %verify --relax-definite-assignment --allow-deprecation --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype Result = Failure(msg: string) | Success(value: T) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817d.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817d.dfy index fd9b8237fd8..02383b0bdea 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817d.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-817d.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module M { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-854.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-854.dfy index 38a53a66acc..caf67d12265 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-854.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-854.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module M { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-859a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-859a.dfy index 1e26cefe425..29b0c5c41c5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-859a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-859a.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" module Common { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-885.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-885.dfy index b0963673a55..b00160abe75 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-885.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-885.dfy @@ -1,6 +1,6 @@ -// RUN: %exits-with 4 %verify "%s" > "%t" +// RUN: %exits-with 4 %verify --type-system-refresh=false --general-newtypes=false --general-traits=legacy "%s" > "%t" // RUN: %diff "%s.expect" "%t" - +// Note, this file is testing the old resolver. The new resolver requires explicit casts to go from a trait to a class. trait Trait { } class Class extends Trait { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-889b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-889b.dfy index 5c115315e37..871b14a3bac 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-889b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-889b.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %build "%s" > "%t" +// RUN: %exits-with 2 %build --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" // This file tests resolution errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-953.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-953.dfy index a24f468c365..47f7f147740 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-953.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-953.dfy @@ -12,7 +12,7 @@ module C1 refines P { module OtherNamesWithSpecialCharacters?_ { datatype A?_ = A?_ codatatype B?_ = B?_ - trait Tr?_ { var data: int } + trait Tr?_ extends object { var data: int } class Cl?_ extends Tr?_ { } type Threes?_ = x: int | x % 3 == 0 newtype Fives?_ = x: int | x % 5 == 0 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-958.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-958.dfy index b09f091802b..26b257496b8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-958.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-958.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype Atom = MakeAtom(value: int) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968.dfy index 37bbd798766..d6377a4012d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype DT = Make | Create { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968a.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968a.dfy index 39bd39ec5d4..acf993fb398 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968a.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-968a.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype DT = Make | Create { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-970b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-970b.dfy index 48556ec25ec..c49e41eb1e5 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-970b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-970b.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 2 %verify "%s" > "%t" +// RUN: %exits-with 2 %verify --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method UnresolvedRhs(x: int) returns (r: Status) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-977.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-977.dfy index 395de625158..fb3c410e29e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-977.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-977.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --show-hints "%s" > "%t" +// RUN: %exits-with 4 %verify --show-hints --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" datatype Option = Some(value: V) | None diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy index 203be075837..e6dd5d042a7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy @@ -88,8 +88,8 @@ module AritySituations { var f' := F; var g' := G; - var s0 := P(F, 5); // error: F takes 2 arguments, but P expect a function that takes 1 - var s1 := P(G, (2,true)); // fine + // (see method MF below) var s0 := P(F, 5); + var s1 := P(G, (2, true)); // fine var v: () -> real; var w: (()) -> real; @@ -102,6 +102,12 @@ module AritySituations { w := V; // error } + method MF() + { + var s0 := P(F, 5); // error: F takes 2 arguments, but P expect a function that takes 1 + var s1 := P(G, (2, true)); // fine + } + method P(r: T -> U, x: T) returns (u: U) requires r.requires(x) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy.expect index 7379abb83e0..5499b3f3d5d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/ResolveError.dfy.expect @@ -1,23 +1,23 @@ ResolveError.dfy(7,9): Error: the number of left-hand sides (1) and right-hand sides (2) must match for a multi-assignment ResolveError.dfy(8,9): Error: the number of left-hand sides (1) and right-hand sides (2) must match for a multi-assignment ResolveError.dfy(21,6): Error: LHS of assignment must denote a mutable field -ResolveError.dfy(32,12): Error: wrong number of arguments (got 2, but function type 'int ~> int' expects 1: (_#p0: int)) -ResolveError.dfy(36,21): Error: wrong number of arguments (got 2, but function 'requires' expects 1: (x0: T0)) -ResolveError.dfy(39,18): Error: wrong number of arguments (got 2, but function 'reads' expects 1: (x0: T0)) -ResolveError.dfy(31,16): Error: arguments must have comparable types (got int and bool) -ResolveError.dfy(33,13): Error: incorrect argument type for function application parameter (expected int, found bool) -ResolveError.dfy(34,22): Error: incorrect argument type for function parameter 'x0' (expected int, found bool) -ResolveError.dfy(37,19): Error: incorrect argument type for function parameter 'x0' (expected int, found bool) -ResolveError.dfy(35,25): Error: arguments must have comparable types (got bool and int) -ResolveError.dfy(38,22): Error: arguments must have comparable types (got set and int) -ResolveError.dfy(47,18): Error: Precondition must be boolean (got int) +ResolveError.dfy(32,12): Error: wrong number of arguments (function type 'int -> int' expects 1, got 2) +ResolveError.dfy(36,21): Error: wrong number of arguments (function 'requires' expects 1, got 2) +ResolveError.dfy(39,18): Error: wrong number of arguments (function 'reads' expects 1, got 2) +ResolveError.dfy(31,19): Error: boolean literal used as if it had type int +ResolveError.dfy(33,13): Error: boolean literal used as if it had type int +ResolveError.dfy(34,22): Error: boolean literal used as if it had type int +ResolveError.dfy(35,28): Error: integer literal used as if it had type bool +ResolveError.dfy(37,19): Error: boolean literal used as if it had type int +ResolveError.dfy(38,25): Error: integer literal used as if it had type set ResolveError.dfy(46,15): Error: a reads-clause expression must denote an object, a set/iset/multiset/seq of objects, or a function to a set/iset/multiset/seq of objects (instead got int) -ResolveError.dfy(56,9): Error: condition is expected to be of type bool, but is () -> bool -ResolveError.dfy(59,42): Error: type of 'null' is a reference type, but it is used as A -> B +ResolveError.dfy(47,18): Error: precondition must be boolean (got int) +ResolveError.dfy(56,9): Error: condition is expected to be of type bool, but is () ~> bool +ResolveError.dfy(59,42): Error: type of 'null' is a reference type, but it is used as A ~> B ResolveError.dfy(62,11): Error: arguments must have comparable types (got A -> B and object) ResolveError.dfy(68,24): Error: unresolved identifier: _ -ResolveError.dfy(86,6): Error: RHS (of type ((int, bool)) -> real) not assignable to LHS (of type (int, bool) -> real) -ResolveError.dfy(101,6): Error: RHS (of type (()) -> real) not assignable to LHS (of type () -> real) -ResolveError.dfy(102,6): Error: RHS (of type () -> real) not assignable to LHS (of type (()) -> real) -ResolveError.dfy(91,16): Error: incorrect argument type at index 0 for method in-parameter 'r' (expected int -> ?, found (int, bool) -> real) +ResolveError.dfy(86,6): Error: RHS (of type ((int, bool)) ~> real) not assignable to LHS (of type (int, bool) -> real) +ResolveError.dfy(101,6): Error: RHS (of type (()) ~> real) not assignable to LHS (of type () -> real) +ResolveError.dfy(102,6): Error: RHS (of type () ~> real) not assignable to LHS (of type (()) -> real) +ResolveError.dfy(107,16): Error: incorrect argument type at index 0 for method in-parameter 'r' (expected ?12 -> ?13, found (int, bool) ~> real) 22 resolution/type errors detected in ResolveError.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Types.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Types.dfy.expect index a9493c0c61e..2dc72df8092 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Types.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Types.dfy.expect @@ -1,5 +1,5 @@ Types.dfy(9,20): Error: arguments must have comparable types (got A -> A -> A and (A -> A) -> A) -Types.dfy(14,20): Error: arguments must have comparable types (got (A -> A) -> A and A -> A -> A) -Types.dfy(18,20): Error: arguments must have comparable types (got A -> A -> A and (A -> A) -> A) -Types.dfy(26,8): Error: a reads-clause expression must denote an object, a set/iset/multiset/seq of objects, or a function to a set/iset/multiset/seq of objects (instead got () -> object) +Types.dfy(14,20): Error: arguments must have comparable types (got (A -> A) -> A and A ~> A ~> A) +Types.dfy(18,20): Error: arguments must have comparable types (got A -> A -> A and (A ~> A) ~> A) +Types.dfy(26,8): Error: a reads-clause expression must denote an object, a set/iset/multiset/seq of objects, or a function to a set/iset/multiset/seq of objects (instead got () ~> object) 4 resolution/type errors detected in Types.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Underspecified.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Underspecified.dfy.expect index a73b94b24c6..2eed66fe883 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Underspecified.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/hofs/Underspecified.dfy.expect @@ -1,8 +1,8 @@ -Underspecified.dfy(6,6): Error: the type of this variable is underspecified +Underspecified.dfy(6,6): Error: the type ('?9 ~> int') of this variable is underspecified Underspecified.dfy(6,11): Error: type of bound variable '_v0' could not be determined; please specify the type explicitly -Underspecified.dfy(7,6): Error: the type of this variable is underspecified +Underspecified.dfy(7,6): Error: the type ('(?11, ?12) ~> int') of this variable is underspecified Underspecified.dfy(7,12): Error: type of bound variable '_v1' could not be determined; please specify the type explicitly Underspecified.dfy(7,15): Error: type of bound variable '_v2' could not be determined; please specify the type explicitly -Underspecified.dfy(8,6): Error: the type of this variable is underspecified +Underspecified.dfy(8,6): Error: the type ('?14 ~> ?14') of this variable is underspecified Underspecified.dfy(8,11): Error: type of bound variable 'a' could not be determined; please specify the type explicitly 7 resolution/type errors detected in Underspecified.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/MatrixAssoc.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/MatrixAssoc.dfy index 56bcdc535af..6aef946cf42 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/MatrixAssoc.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/MatrixAssoc.dfy @@ -1,4 +1,4 @@ -// RUN: %verify --allow-axioms "%s" > "%t" +// RUN: %verify --allow-axioms --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" type Pos = x | 0 < x witness 1 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/StateMonad.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/StateMonad.dfy index 74b667a060d..1d34f8371af 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/StateMonad.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/lambdas/StateMonad.dfy @@ -1,4 +1,4 @@ -// RUN: %build "%s" > "%t" +// RUN: %build "%s" --type-system-refresh=false --general-newtypes=false > "%t" // RUN: %diff "%s.expect" "%t" abstract module Monad { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy index 19ec978d8bf..630718fbddd 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy @@ -1,6 +1,14 @@ -// RUN: %verify --warn-missing-constructor-parentheses "%s" --allow-warnings > "%t" +// RUN: %exits-with 2 %verify --warn-missing-constructor-parentheses "%s" --allow-warnings > "%t" // RUN: %diff "%s.expect" "%t" +/* These tests were originally designed to test --warn-missing-constructor-parentheses, which reported + * a warning when a nullary constructor in a match-case did not include parentheses. + * + * In the new resolver, that option has been superseded by reporting an error if a non-nullary + * constructor is used without arguments. The use of the --warn-missing-constructor-parentheses option + * in this test is thus not necessary. + */ + module WithWarning { datatype Color = Red | Green | ShadesOfGray(nat) datatype Identity = Identity(value: T) @@ -19,13 +27,13 @@ module WithWarning { } method MonochromaticMethod(c: Color) returns (x: bool) { return match c - case ShadesOfGray => true + case ShadesOfGray => true // error: needs arguments case Green => true case anythingElse => false; } function MonochromaticFunction(c: Color) : bool { match c - case ShadesOfGray => true + case ShadesOfGray => true // error: needs arguments case Green => true case anythingElse => false } @@ -34,7 +42,7 @@ module WithWarning { while test { test := match c - case ShadesOfGray => true + case ShadesOfGray => true // error: needs arguments case Green => true case anythingElse => false; } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy.expect index 7eaf997b5e4..7240cd13e19 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/linters/constructorCaseWithoutParentheses.dfy.expect @@ -1,14 +1,4 @@ -constructorCaseWithoutParentheses.dfy(23,6): Warning: this branch is redundant -constructorCaseWithoutParentheses.dfy(24,6): Warning: this branch is redundant -constructorCaseWithoutParentheses.dfy(29,6): Warning: this branch is redundant -constructorCaseWithoutParentheses.dfy(30,6): Warning: this branch is redundant -constructorCaseWithoutParentheses.dfy(38,9): Warning: this branch is redundant -constructorCaseWithoutParentheses.dfy(39,9): Warning: this branch is redundant -constructorCaseWithoutParentheses.dfy(11,11): Warning: Constructor name 'A' should be followed by parentheses -constructorCaseWithoutParentheses.dfy(12,11): Warning: Constructor name 'B' should be followed by parentheses -constructorCaseWithoutParentheses.dfy(17,20): Warning: Constructor name 'Blue' should be followed by parentheses -constructorCaseWithoutParentheses.dfy(23,11): Warning: Constructor name 'Green' should be followed by parentheses -constructorCaseWithoutParentheses.dfy(29,11): Warning: Constructor name 'Green' should be followed by parentheses -constructorCaseWithoutParentheses.dfy(38,14): Warning: Constructor name 'Green' should be followed by parentheses - -Dafny program verifier finished with 5 verified, 0 errors +constructorCaseWithoutParentheses.dfy(30,11): Error: constructor 'ShadesOfGray' of arity 1 is applied without any arguments +constructorCaseWithoutParentheses.dfy(36,11): Error: constructor 'ShadesOfGray' of arity 1 is applied without any arguments +constructorCaseWithoutParentheses.dfy(45,14): Error: constructor 'ShadesOfGray' of arity 1 is applied without any arguments +3 resolution/type errors detected in constructorCaseWithoutParentheses.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/lit.site.cfg b/Source/IntegrationTests/TestFiles/LitTests/LitTest/lit.site.cfg index d7945a938f1..c47f6ae4321 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/lit.site.cfg +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/lit.site.cfg @@ -199,6 +199,7 @@ config.substitutions.append( ('%ver', ver ) ) config.substitutions.append( ('%sed', 'sed -E' ) ) config.substitutions.append( ('%exits-with', "python3 " + os.path.join(repositoryRoot, 'Scripts/test-exit.py') ) ) config.substitutions.append( ('!', "python3 " + os.path.join(repositoryRoot, 'Scripts/test-exit.py') + " -z" ) ) +config.substitutions.append( ('%cargo', 'cargo' ) ) if os.name == "nt": config.available_features = [ 'windows' ] diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy index b3ceae90dd9..77c60cb187a 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy @@ -1,20 +1,19 @@ // RUN: %exits-with 2 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" -module SanityChecks { - datatype T = A(int) | B(nat) | C(bool) - method Variables(t: T) { - match t - case A(n) // Error: Or-patterns may not bind variables - | B(n) => // Error: Or-patterns may not bind variables - case _ => - } +datatype T = A(int) | B(nat) | C(bool) - method Nesting(t: T) { - match t - case A(1 | 2 | _) => // Error: Or-patterns are not allowed inside other patterns - case B(0 | _) // Error: Or-patterns are not allowed inside other patterns - | C(_ | _ | _) => // Error: Or-patterns are not allowed inside other patterns - } +method Variables(t: T) { + match t + case A(n) // Error: Or-patterns may not bind variables + | B(n) => // Error: Or-patterns may not bind variables AND Error: duplicate name + case _ => +} + +method Nesting(t: T) { + match t + case A(1 | 2 | _) => // Error: Or-patterns are not allowed inside other patterns + case B(0 | _) // Error: Or-patterns are not allowed inside other patterns + | C(_ | _ | _) => // Error: Or-patterns are not allowed inside other patterns } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy.expect index 48e97b18829..62a827a57b0 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatternErrors.dfy.expect @@ -1,6 +1,7 @@ -OrPatternErrors.dfy(9,13): Error: Disjunctive patterns may not bind variables -OrPatternErrors.dfy(10,13): Error: Disjunctive patterns may not bind variables -OrPatternErrors.dfy(16,13): Error: Disjunctive patterns are not allowed inside other patterns -OrPatternErrors.dfy(17,13): Error: Disjunctive patterns are not allowed inside other patterns -OrPatternErrors.dfy(18,13): Error: Disjunctive patterns are not allowed inside other patterns -5 resolution/type errors detected in OrPatternErrors.dfy +OrPatternErrors.dfy(9,11): Error: Disjunctive patterns may not bind variables +OrPatternErrors.dfy(10,11): Error: Disjunctive patterns may not bind variables +OrPatternErrors.dfy(10,11): Error: Duplicate parameter name: n +OrPatternErrors.dfy(16,11): Error: Disjunctive patterns are not allowed inside other patterns +OrPatternErrors.dfy(17,11): Error: Disjunctive patterns are not allowed inside other patterns +OrPatternErrors.dfy(18,11): Error: Disjunctive patterns are not allowed inside other patterns +6 resolution/type errors detected in OrPatternErrors.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/constructorInsteadOfTuple.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/constructorInsteadOfTuple.dfy.expect index 4c346e0489a..c7547badf10 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/constructorInsteadOfTuple.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/constructorInsteadOfTuple.dfy.expect @@ -1,2 +1,2 @@ -constructorInsteadOfTuple.dfy(21,21): Error: found constructor Mult but expected a 2-tuple +constructorInsteadOfTuple.dfy(21,21): Error: type '(Expr, Expr)' does not contain a datatype constructor 'Mult' 1 resolution/type errors detected in constructorInsteadOfTuple.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/indices-in-domain.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/indices-in-domain.dfy.expect index c56d6bf7762..4ca64a55421 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/indices-in-domain.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/indices-in-domain.dfy.expect @@ -1,7 +1,7 @@ indices-in-domain.dfy(5,14): Error: all array indices must be in the domain of the initialization function - Asserted expression: forall i0: int | 0 <= i0 < 1 :: ((i: nat) requires i > 0 => 1).requires(i0) + Asserted expression: forall i0: int | 0 <= i0 < 1 :: ((i: int) requires i > 0 => 1).requires(i0) indices-in-domain.dfy(6,14): Error: all array indices must be in the domain of the initialization function - Asserted expression: forall i0: int, i1: int | (0 <= i0 < 1) && (0 <= i1 < 1) :: ((i: nat, j: int) requires i > 0 && j < 0 => 1).requires(i0, i1) + Asserted expression: forall i0: int, i1: int | (0 <= i0 < 1) && (0 <= i1 < 1) :: ((i: int, j: int) requires i > 0 && j < 0 => 1).requires(i0, i1) indices-in-domain.dfy(7,13): Error: all sequence indices must be in the domain of the initialization function Asserted expression: forall i0: int | 0 <= i0 < 1 :: ((i: int) requires i > 0 => 1).requires(i0) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/read-frame-subset.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/read-frame-subset.dfy.expect index 433c7c55637..99bd949fd73 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/read-frame-subset.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/read-frame-subset.dfy.expect @@ -3,11 +3,11 @@ read-frame-subset.dfy(15,7): Error: insufficient reads clause to read field; Con read-frame-subset.dfy(15,22): Error: insufficient reads clause to read field; Consider adding 'reads s[1]' or 'reads s[1]`y' in the enclosing function specification for resolution Asserted expression: s[1] == s[2] || s[1] in {s[3]} || s[1] in {s[4]} read-frame-subset.dfy(23,30): Error: insufficient reads clause to read array element; Consider adding 'reads s[0]' in the enclosing function specification for resolution - Asserted expression: s[0] == s[1] || s[0] in set a: array {:trigger a in s[2..]} | a in s[2..] + Asserted expression: s[0] == s[1] || s[0] in set a: array? {:trigger a in s[2..]} | a in s[2..] read-frame-subset.dfy(31,30): Error: insufficient reads clause to read the indicated range of array elements; Consider adding 'reads s[0]' in the enclosing function specification for resolution - Asserted expression: s[0] == s[1] || s[0] in set a: array {:trigger a in s[2..]} | a in s[2..] + Asserted expression: s[0] == s[1] || s[0] in set a: array? {:trigger a in s[2..]} | a in s[2..] read-frame-subset.dfy(39,51): Error: insufficient reads clause to read array element; Consider adding 'reads s[0]' in the enclosing function specification for resolution - Asserted expression: s[0] == s[1] || s[0] in set a: array2 {:trigger a in s[2..]} | a in s[2..] + Asserted expression: s[0] == s[1] || s[0] in set a: array2? {:trigger a in s[2..]} | a in s[2..] read-frame-subset.dfy(54,2): Error: insufficient reads clause to invoke function Asserted expression: forall obj: object? | obj in lam.reads(s) :: obj == s[3] || obj in {s[4]} || obj in {s[5]} read-frame-subset.dfy(72,17): Error: insufficient reads clause to invoke function diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/subrange-check-no-type-system-refresh.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/subrange-check-no-type-system-refresh.dfy index a76c023b66d..8a3c4beecfe 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/subrange-check-no-type-system-refresh.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/proof-obligation-desc/subrange-check-no-type-system-refresh.dfy @@ -1,4 +1,4 @@ -// RUN: %exits-with 4 %verify --show-proof-obligation-expressions "%s" > "%t" +// RUN: %exits-with 4 %verify --show-proof-obligation-expressions --type-system-refresh=false --general-newtypes=false "%s" > "%t" // RUN: %diff "%s.expect" "%t" method SubrangeCheck(o: object?, p: T --> U, r: T ~> U, i: int) { @@ -6,4 +6,4 @@ method SubrangeCheck(o: object?, p: T --> U, r: T ~> U, i: int) { var totalVar: T -> U := p; var partialVar: T --> U := r; var natVar: nat := i; -} \ No newline at end of file +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/separate-verification/assumptions.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/separate-verification/assumptions.dfy.expect index 4034e917d44..d11edc9e40c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/separate-verification/assumptions.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/separate-verification/assumptions.dfy.expect @@ -5,11 +5,11 @@ TestAuditor.dfy(50,17): Warning: when a method is exported, meaning it has a bod TestAuditor.dfy(72,19): Warning: when a function is imported, meaning it has no body and an {:extern} annotation, Dafny can not guarantee that its implementation satisfies its post-conditions (its ensures clauses and outputs that are subset types). To silence this warning, please add an {:axiom} attribute or use the option '--allow-external-contracts'. TestAuditor.dfy(136,2): Warning: assume statement has no {:axiom} annotation TestAuditor.dfy(150,11): Warning: Assertion with {:only} temporarily transforms other assertions into assumptions -TestAuditor.dfy(154,9): Warning: Members with {:only} temporarily disable the verification of other members in the entire file TestAuditor.dfy(95,4): Warning: this forall statement has no body TestAuditor.dfy(102,4): Warning: this loop has no body (loop frame: i) TestAuditor.dfy(139,2): Warning: this forall statement has no body TestAuditor.dfy(143,2): Warning: this loop has no body (loop frame: i) +TestAuditor.dfy(154,9): Warning: Members with {:only} temporarily disable the verification of other members in the entire file TestAuditor.dfy(93,10): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. TestAuditor.dfy(95,4): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. TestAuditor.dfy(139,2): Warning: Could not find a trigger for this quantifier. Without a trigger, the quantifier may cause brittle verification. To silence this warning, add an explicit trigger using the {:trigger} attribute. For more information, see the section quantifier instantiation rules in the reference manual. diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy index 6f45dc10488..a50e74bc7bb 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy @@ -457,7 +457,7 @@ module ComparableTypes1 { method NonReferenceEquality(a: TraitA, b: TraitB) { var r; - r := a == b; // error: TraitA and TraitB are incomparable + r := a == b; // error: TraitA and TraitB don't necessarily support equality } } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy.expect index 2ef5bdfedfe..fbd040ed7f7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/NonReferenceTraits.dfy.expect @@ -104,7 +104,7 @@ NonReferenceTraits.dfy(447,11): Error: arguments must have comparable types (got NonReferenceTraits.dfy(448,11): Error: arguments must have comparable types (got object and TraitB) NonReferenceTraits.dfy(449,11): Error: arguments must have comparable types (got TraitA and object) NonReferenceTraits.dfy(450,11): Error: arguments must have comparable types (got TraitB and object) -NonReferenceTraits.dfy(460,11): Error: arguments must have comparable types (got TraitA and TraitB) +NonReferenceTraits.dfy(460,9): Error: == can only be applied to expressions of types that support equality (got TraitA) NonReferenceTraits.dfy(470,9): Error: == can only be applied to expressions of types that support equality (got TraitA) NonReferenceTraits.dfy(471,9): Error: == can only be applied to expressions of types that support equality (got TraitB) NonReferenceTraits.dfy(472,14): Error: set argument type must support equality (got TraitA) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitBasix.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitBasix.dfy.refresh.expect index 59b01f70652..32baacac987 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitBasix.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitBasix.dfy.refresh.expect @@ -4,5 +4,5 @@ TraitBasix.dfy(80,8): Error: class 'I0Child2' does not implement trait function TraitBasix.dfy(91,24): Error: Type or type parameter is not declared in this scope: IX (did you forget to qualify a name or declare a module import 'opened'?) (note that names in outer modules are not visible in contained modules) TraitBasix.dfy(101,16): Error: a trait is not allowed to declare a constructor TraitBasix.dfy(117,14): Error: new can be applied only to class types (got I1) -TraitBasix.dfy(184,6): Error: RHS (of type B) not assignable to LHS (of type Tr?) (non-variant type parameter 'X' would require int = real) +TraitBasix.dfy(184,6): Error: RHS (of type B) not assignable to LHS (of type Tr) (non-variant type parameter 'X' would require int = real) 7 resolution/type errors detected in TraitBasix.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitCompile.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitCompile.dfy index fdf3ffcb553..9462959386c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitCompile.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitCompile.dfy @@ -1,4 +1,4 @@ -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment --type-system-refresh=true trait TT { @@ -107,7 +107,7 @@ module OtherModule { module TestFields { - trait J { + trait J extends object { var f: int } @@ -130,7 +130,7 @@ module TestFields { module GenericBasics { // To compile these correctly requires that certain type-parameter renamings be done. - trait Tr { + trait Tr extends object { var xyz: B const abc: B static const def: B @@ -395,7 +395,7 @@ module TraitsExtendingTraits { In addition, for further testing, M, C, and G list "object" in the "extends" clause. */ - trait A { + trait A extends object { var y0: Y0 const y1: Y1 method SetY(y: Y0) @@ -411,7 +411,7 @@ module TraitsExtendingTraits { function GetY'(): Y0 reads this } - trait B { + trait B extends object { var b: bool method Quantity() returns (x: int) method Twice() returns (x: int) @@ -517,7 +517,7 @@ module TypeDescriptorTests { } // Go requires coercions to supertypes. Coersions involving functions require more work. - trait XT { + trait XT extends object { const c: U var u: U function F(u: U): U { u } @@ -584,7 +584,7 @@ module TypeDescriptorTests { print f(7), "\n"; } - trait TraitDependency { + trait TraitDependency extends object { const a: X const b: (X, X) := (a, c) const c: X @@ -612,7 +612,7 @@ module DiamondInitialization { M + */ - trait A { + trait A extends object { var x: XA } trait B extends A { } @@ -692,7 +692,7 @@ module NonCapturingFunctionCoercions { } module TailRecursion { - trait Trait { + trait Trait extends object { var h: G var K: G function Id(g: G): G { g } @@ -747,7 +747,7 @@ module ObjectEquality { TestSequences(); } - trait A { } + trait A extends object { } trait B extends A { } @@ -802,7 +802,7 @@ module RedeclaringMembers { // in an extending trait (for target languages that require it, such as Go). // The code below would lead to a target-compiler // error because B would include Valid() even though it was ghost. - trait A { + trait A extends object { ghost var Foo: int predicate Valid() } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExample.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExample.dfy index 0a724cf53b3..5738b6e29f7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExample.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExample.dfy @@ -1,6 +1,6 @@ // RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment -trait Automobile { +trait Automobile extends object { ghost var Repr: set ghost predicate Valid() reads this, Repr diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExtend.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExtend.dfy.expect index be3a9b577b8..0be27ccb8d8 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExtend.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitExtend.dfy.expect @@ -1,3 +1,3 @@ -TraitExtend.dfy(40,21): Error: wrong number of arguments (got 2, but function 'Mul' expects 3: (x: int, y: int, z: int)) -TraitExtend.dfy(41,21): Error: wrong number of arguments (got 3, but function 'Plus' expects 2: (x: int, y: int)) +TraitExtend.dfy(40,21): Error: wrong number of arguments (function 'Mul' expects 3, got 2) +TraitExtend.dfy(41,21): Error: wrong number of arguments (function 'Plus' expects 2, got 3) 2 resolution/type errors detected in TraitExtend.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitOverride2.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitOverride2.dfy index f0be6b63540..affbe97f982 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitOverride2.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitOverride2.dfy @@ -1,7 +1,7 @@ // RUN: %verify --relax-definite-assignment --allow-axioms "%s" > "%t" // RUN: %diff "%s.expect" "%t" -trait Spec { +trait Spec extends object { var done: bool var hasFailed: bool ghost const Repr: set diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy index d8cf37048de..336e7e09458 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy @@ -1,34 +1,34 @@ -// RUN: %exits-with 2 %verify --allow-deprecation "%s" > "%t" +// RUN: %exits-with 2 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" trait T1 { - var f: int; + var f: int - function Plus (x:int, y:int) : int - requires x>y; - { - x + y - } + function Plus(x: int, y: int): int + requires x > y + { + x + y + } - function Mul (x:int, y:int, z:int) : int - requires x>y; - { - x * y * z - } + function Mul(x: int, y: int, z: int): int + requires x > y + { + x * y * z + } - //function BodyLess1() : int + //function BodyLess1() : int - static method GetPhoneNumber (code:int, n:int) returns (z:int) - { - z := code + n; - } + static method GetPhoneNumber(code: int, n: int) returns (z: int) + { + z := code + n; + } - method TestPhone () - { - var num : int; - num := GetPhoneNumber (10, 30028); - } + method TestPhone() + { + var num: int; + num := GetPhoneNumber(10, 30028); + } } trait T2 @@ -37,29 +37,29 @@ trait T2 class C1 extends T1 { - method P2(x:int, y:int) returns (z:int) - requires x>y; - { - z:= Plus(x,y) + Mul (x,y,1); - } + method P2(x: int, y: int) returns (z: int) + requires x > y + { + z := Plus(x, y) + Mul(x, y, 1); + } } method Good() returns (c: C1, t: T1) -ensures c == t; + ensures c == t { - t := c; + t := c; } method Bad1() returns (c: C1, t: T2) -ensures c == t; + ensures c == t { - t := c; //error, C1 has not implemented T2 + t := c; //error, C1 has not implemented T2 } method Bad2() returns (c: C1, t: T1) -ensures c == t; + ensures c == t { - c := t; // OK for type resolution, but must be proved + c := t as C1; // OK for type resolution, but must be proved } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy.expect index 3db8f8a52ce..b599a2e901e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitPolymorphism.dfy.expect @@ -1,3 +1,3 @@ -TraitPolymorphism.dfy(56,10): Error: arguments must have comparable types (got C1 and T2) -TraitPolymorphism.dfy(58,6): Error: RHS (of type C1) not assignable to LHS (of type T2) +TraitPolymorphism.dfy(56,12): Error: arguments must have comparable types (got C1 and T2) +TraitPolymorphism.dfy(58,4): Error: RHS (of type C1) not assignable to LHS (of type T2) 2 resolution/type errors detected in TraitPolymorphism.dfy diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy index d1f83c095be..683e1cc6d14 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy @@ -18,7 +18,7 @@ module M0 { } module M1 { - trait Tr { + trait Tr extends object { var w: X } @@ -45,6 +45,32 @@ module M2 { } } +module M3 { + trait Tr { + const w: X // const in non-reference trait + } + + class Cl extends Tr<(Y,Y)> { + } + + lemma M(c: Cl) { + var x := c.w; // (int, int) + } +} + +module M4 { + trait Tr extends object { + const w: X // const in reference trait + } + + class Cl extends Tr<(Y,Y)> { + } + + lemma M(c: Cl) { + var x := c.w; // (int, int) + } +} + module P0 { trait TrX { ghost function F(x: X): int { 15 } @@ -65,7 +91,7 @@ module P0 { } module P1 { - trait TrX { + trait TrX extends object { var w: X } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.expect index 1fe266b9208..2d338148c15 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.expect @@ -182,7 +182,7 @@ module M1 { ghost var x: (int, int) := c.w; } - trait Tr { + trait Tr extends object { var w: X } /*-- non-null type @@ -230,6 +230,66 @@ module M2 { */ } +module M3 { + /* CALL GRAPH for module M3: + * SCC at height 1: + * M + * SCC at height 0: + * Cl + * SCC at height 0: + * Tr + * SCC at height 0: + * Tr.w + */ + lemma M(c: Cl) + decreases c + { + ghost var x: (int, int) := c.w; + } + + trait Tr { + const w: X + } + /*-- non-null type + type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ + */ + + class Cl extends Tr<(Y, Y)> { } + /*-- non-null type + type {:axiom} Cl(==) = c: Cl? | c != null /*special witness*/ + */ +} + +module M4 { + /* CALL GRAPH for module M4: + * SCC at height 1: + * M + * SCC at height 0: + * Cl + * SCC at height 0: + * Tr + * SCC at height 0: + * Tr.w + */ + lemma M(c: Cl) + decreases c + { + ghost var x: (int, int) := c.w; + } + + trait Tr extends object { + const w: X + } + /*-- non-null type + type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ + */ + + class Cl extends Tr<(Y, Y)> { } + /*-- non-null type + type {:axiom} Cl(==) = c: Cl? | c != null /*special witness*/ + */ +} + module P0 { /* CALL GRAPH for module P0: * SCC at height 1: @@ -289,7 +349,7 @@ module P1 { ghost var x: (int, int) := c.w; } - trait TrX { + trait TrX extends object { var w: X } /*-- non-null type @@ -349,4 +409,4 @@ module P2 { */ } -Dafny program verifier finished with 6 verified, 0 errors +Dafny program verifier finished with 8 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.refresh.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.refresh.expect index e23fa482a03..4432dcaa357 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.refresh.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution0.dfy.refresh.expect @@ -145,8 +145,6 @@ module M0 { * SCC at height 0: * Cl * SCC at height 0: - * Tr - * SCC at height 0: * Tr.F */ trait Tr { @@ -155,9 +153,6 @@ module M0 { 15 } } - /*-- non-null type - type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ - */ class Cl extends Tr { lemma M() @@ -188,7 +183,7 @@ module M1 { ghost var x: (int, int) := c.w; } - trait Tr { + trait Tr extends object { var w: X } /*-- non-null type @@ -208,8 +203,6 @@ module M2 { * SCC at height 0: * Cl * SCC at height 0: - * Tr - * SCC at height 0: * Tr.F */ lemma M(c: Cl) @@ -226,9 +219,6 @@ module M2 { 15 } } - /*-- non-null type - type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ - */ class Cl extends Tr<(Y, Y), real> { } /*-- non-null type @@ -236,16 +226,67 @@ module M2 { */ } -module P0 { - /* CALL GRAPH for module P0: +module M3 { + /* CALL GRAPH for module M3: * SCC at height 1: - * Cl.M + * M + * SCC at height 0: + * Cl + * SCC at height 0: + * Tr.w + */ + lemma M(c: Cl) + decreases c + { + ghost var x: (int, int) := c.w; + } + + trait Tr { + const w: X + } + + class Cl extends Tr<(Y, Y)> { } + /*-- non-null type + type {:axiom} Cl(==) = c: Cl? | c != null /*special witness*/ + */ +} + +module M4 { + /* CALL GRAPH for module M4: + * SCC at height 1: + * M * SCC at height 0: * Cl * SCC at height 0: * Tr * SCC at height 0: - * TrX + * Tr.w + */ + lemma M(c: Cl) + decreases c + { + ghost var x: (int, int) := c.w; + } + + trait Tr extends object { + const w: X + } + /*-- non-null type + type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ + */ + + class Cl extends Tr<(Y, Y)> { } + /*-- non-null type + type {:axiom} Cl(==) = c: Cl? | c != null /*special witness*/ + */ +} + +module P0 { + /* CALL GRAPH for module P0: + * SCC at height 1: + * Cl.M + * SCC at height 0: + * Cl * SCC at height 0: * TrX.F */ @@ -255,14 +296,8 @@ module P0 { 15 } } - /*-- non-null type - type {:axiom} TrX(==) = c: TrX? | c != null /*special witness*/ - */ trait Tr extends TrX { } - /*-- non-null type - type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ - */ class Cl extends Tr { lemma M() @@ -295,7 +330,7 @@ module P1 { ghost var x: (int, int) := c.w; } - trait TrX { + trait TrX extends object { var w: X } /*-- non-null type @@ -320,10 +355,6 @@ module P2 { * SCC at height 0: * Cl * SCC at height 0: - * Tr - * SCC at height 0: - * TrX - * SCC at height 0: * TrX.F */ lemma M(c: Cl) @@ -340,14 +371,8 @@ module P2 { 15 } } - /*-- non-null type - type {:axiom} TrX(==) = c: TrX? | c != null /*special witness*/ - */ trait Tr extends TrX { } - /*-- non-null type - type {:axiom} Tr(==) = c: Tr? | c != null /*special witness*/ - */ class Cl extends Tr<(Y, Y), real> { } /*-- non-null type @@ -355,4 +380,4 @@ module P2 { */ } -Dafny program verifier finished with 6 verified, 0 errors +Dafny program verifier finished with 8 verified, 0 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution1.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution1.dfy index 9a21c0e17c4..843e8b62351 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution1.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution1.dfy @@ -18,7 +18,7 @@ module M0 { } module M1 { - trait Tr { + trait Tr extends object { var w: X } @@ -67,7 +67,7 @@ module M4 { } module NewMustMentionAClassName { - trait Tr { + trait Tr extends object { method Make() { } } @@ -442,7 +442,7 @@ module ProvidingModule { provides Klass, Klass.M, Klass.N provides Dt, Dt.M, Dt.N - trait Trait { + trait Trait extends object { const M := 100 ghost const N: AA } @@ -469,7 +469,7 @@ module ImporterOfProvidingModule { } module NeedForConstructors { - trait Tr { + trait Tr extends object { var w: X } @@ -486,7 +486,7 @@ module NeedForConstructors { } module TypeCharacteristicsDiscrepancies { - trait RequiresZero { + trait RequiresZero extends object { var x: X } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution2.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution2.dfy index 494b54b9c32..1ff4f465036 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution2.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitResolution2.dfy @@ -19,7 +19,7 @@ module M0 { } module M1 { - trait TrX { + trait TrX extends object { var w: X } trait Tr extends TrX { @@ -75,7 +75,7 @@ module NewMustMentionAClassName { trait TrX { method Make() { } } - trait Tr extends TrX { } + trait Tr extends TrX, object { } class A extends Tr { } class B extends Tr { constructor () { } } class C extends Tr { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy index a2a7c4b97c8..062d40920e2 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy @@ -1,7 +1,7 @@ // RUN: %exits-with 4 %verify "%s" > "%t" // RUN: %diff "%s.expect" "%t" -trait Tr { } +trait Tr extends object { } class A extends Tr { } class B extends Tr { } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy.expect index d2b472b38a7..d4be00f5cb7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitVerify.dfy.expect @@ -2,4 +2,4 @@ TraitVerify.dfy(21,7): Error: value of expression (of type 'C?') is not kno TraitVerify.dfy(25,7): Error: value of expression (of type 'A?') is not known to be an instance of type 'Tr' TraitVerify.dfy(30,7): Error: value of expression (of type 'A?') is not known to be an instance of type 'A', because it might be null -Dafny program verifier finished with 5 verified, 3 errors +Dafny program verifier finished with 6 verified, 3 errors diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/Traits-Fields.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/Traits-Fields.dfy index 7e6700344a1..47643e4c535 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/Traits-Fields.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/Traits-Fields.dfy @@ -1,6 +1,6 @@ // RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment -trait J +trait J extends object { var x: int } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsDecreases.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsDecreases.dfy index 11e067a6aa9..37017bd548e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsDecreases.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsDecreases.dfy @@ -131,7 +131,7 @@ module More { ghost predicate P(x: int) reads this // error: rank is not lower } - trait A3 { + trait A3 extends object { ghost predicate P() reads this } class B3 extends A3 { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsMultipleInheritance.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsMultipleInheritance.dfy index 1fc3f234267..a000e2fbb9d 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsMultipleInheritance.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/traits/TraitsMultipleInheritance.dfy @@ -1,14 +1,14 @@ // RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --relax-definite-assignment -trait J1{ +trait J1 extends object { var x: int } -trait J2{ +trait J2 extends object { var y: int } -class C extends J1, J2{ +class C extends J1, J2 { } method Main() diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/unicodecharsFalse/comp/Numbers.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/unicodecharsFalse/comp/Numbers.dfy index 1d1361ddb1f..a56e26222ca 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/unicodecharsFalse/comp/Numbers.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/unicodecharsFalse/comp/Numbers.dfy @@ -1,3 +1,3 @@ // NONUNIFORM: https://github.com/dafny-lang/dafny/issues/4174 -// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --allow-deprecation --relax-definite-assignment --unicode-char false --verify-included-files +// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" -- --type-system-refresh=false --general-newtypes=false --allow-deprecation --relax-definite-assignment --unicode-char false --verify-included-files include "../../comp/Numbers.dfy" diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/vacid0/LazyInitArray.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/vacid0/LazyInitArray.dfy index b47f2722788..54eb43ceca3 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/vacid0/LazyInitArray.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/vacid0/LazyInitArray.dfy @@ -16,7 +16,7 @@ class LazyInitArray { a.Length == |Contents| && b.Length == |Contents| && c.Length == |Contents| && - b != c && a != b && a != c && + b != c && a as object != b && a as object != c && 0 <= n && n <= c.Length && (forall i :: 0 <= i && i < |Contents| ==> Contents[i] == (if 0 <= b[i] && b[i] < n && c[b[i]] == i then a[i] else Zero)) && diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/wishlist/GoModule.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/wishlist/GoModule.dfy index 338c167d0e2..8f638884566 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/wishlist/GoModule.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/wishlist/GoModule.dfy @@ -26,7 +26,7 @@ module {:extern "url", "net/url"} {:dummyImportMember "URL", true} URL { var {:extern "RawQuery"} search: string } - trait {:extern "", "error"} Error { } + trait {:extern "", "error"} Error extends object { } } module {:extern "GoModuleConversions"} {:dummyImportMember "ParseURL", false} GoModuleConversions { diff --git a/Source/TestDafny/MultiBackendTest.cs b/Source/TestDafny/MultiBackendTest.cs index ea81a97689c..4dce44cc395 100644 --- a/Source/TestDafny/MultiBackendTest.cs +++ b/Source/TestDafny/MultiBackendTest.cs @@ -205,7 +205,7 @@ await output.WriteLineAsync( var success = true; foreach (var plugin in plugins) { foreach (var compiler in plugin.GetCompilers(DafnyOptions.Default)) { - if (!compiler.IsStable || compilerFilter.Any() && !compilerFilter.Contains(compiler.TargetId)) { + if (!compiler.IsStable || (compilerFilter.Any() && !compilerFilter.Contains(compiler.TargetId))) { continue; } diff --git a/docs/HowToFAQ/Errors-Parser.md b/docs/HowToFAQ/Errors-Parser.md index 9fc4c067a51..6b5cc2f483b 100644 --- a/docs/HowToFAQ/Errors-Parser.md +++ b/docs/HowToFAQ/Errors-Parser.md @@ -250,6 +250,7 @@ It is only allowed to add members to the body of the datatype. ## **Error: datatype extending traits is not yet enabled by default; use --general-traits=datatype to enable it** {#p_general_traits_datatype} + ```dafny trait Trait { } datatype D extends Trait = A | B diff --git a/docs/HowToFAQ/Errors-Parser.template b/docs/HowToFAQ/Errors-Parser.template index f5e57a773e8..a193172b44e 100644 --- a/docs/HowToFAQ/Errors-Parser.template +++ b/docs/HowToFAQ/Errors-Parser.template @@ -206,6 +206,7 @@ module N refines M { datatype D = ... Y | Z } ## **Error: datatype extending traits is not yet enabled by default; use --general-traits=datatype to enable it** {#p_general_traits_datatype} + ```dafny trait Trait { } datatype D extends Trait = A | B diff --git a/docs/HowToFAQ/Errors-Resolution.md b/docs/HowToFAQ/Errors-Resolution.md index 728e0325133..f8aeb81a8d4 100644 --- a/docs/HowToFAQ/Errors-Resolution.md +++ b/docs/HowToFAQ/Errors-Resolution.md @@ -260,7 +260,7 @@ context, such as a print statement. ## **Error: shared destructors must have the same type, but '_name_' has type '_type_' in constructor '_name_' and type '_type_' in constructor '_name_'** {#r_shared_destructors_have_different_types} ```dafny -datatype D = A(x: int) | B (x: bool) +datatype D = A(x: int) | B(x: bool) ``` In defining a datatype, two constructors can both refer to a common destructor, but if they @@ -353,6 +353,7 @@ a syntax that explicitly states that the writer means it. ## **Error: a non-trivial type test is allowed only for reference types (tried to test if '_type_' is a '_type_')** {#r_unsupported_type_test} + ```dafny type Small = i: nat | i < 10 const i := 10 @@ -398,7 +399,7 @@ or the test is unnecessary. ## **Warning: the type of the other operand is a map to a non-null type, so the inclusion test of 'null' will always return '_bool_'** {#r_trivial_map_null_inclusion_test} - + ```dafny trait T {} const m: map diff --git a/docs/HowToFAQ/Errors-Resolver3.md b/docs/HowToFAQ/Errors-Resolver3.md index 561389d23c6..ab52be00677 100644 --- a/docs/HowToFAQ/Errors-Resolver3.md +++ b/docs/HowToFAQ/Errors-Resolver3.md @@ -3,7 +3,7 @@ -## **Error: newtypes must be based on some numeric type (got _type_)** +## **Error: a newtype ('_type_') must be based on some non-reference, non-trait, non-arrow, non-ORDINAL, non-datatype type (got _type_)** ```dafny datatype D = A | B @@ -26,7 +26,7 @@ of the newtype. This is different than, say, a set comprehension like `set i: int :: i*2` where the expression after the `::` gives the elements of the set directly. -## **Error: subset-type constraint must be of type bool (instead got _type_)** +## **Error: subset type constraint must be of type bool (instead got _type_)** ```dafny type T = i: int | i @@ -40,6 +40,7 @@ of the set directly. ## **Error: witness expression must have type '_type_' (got '_type_')** + ```dafny type T = i: int | 100 < i < 102 witness true ``` @@ -52,7 +53,7 @@ the witness may not be an expression of some different type. -## **Error: the argument of a unary minus must have numeric or bitvector type (instead got _type_)** +## **Error: type of unary - must be of a numeric or bitvector type (instead got _type_)** ```dafny datatype D = A | B @@ -139,7 +140,7 @@ _This error message is not yet documented. Please report any source code that pr const d := [4.0, 6] ``` -## **Error: All domain elements of map display must have some common supertype (got _type_, but needed type or type of previous elements is _type_)** +## **Error: All elements of display must have some common supertype (got _type_, but needed type or type of previous elements is _type_)** ```dafny const d := map[2 := 3, 4.0 := 6] @@ -148,7 +149,7 @@ const d := map[2 := 3, 4.0 := 6] A map display associates a number of domain values with corresponding range values using the syntax _domain value_ := _range value_. All the domain values must have the same type or a common supertype. -## **Error: All range elements of map display must have some common supertype (got _type_, but needed type or type of previous elements is _type_)** +## **Error: All elements of display must have some common supertype (got _type_, but needed type or type of previous elements is _type_)** ```dafny const d := map[2 := 3, 4 := 6.0 ] @@ -323,6 +324,7 @@ from `nat` to values of the element type of the sequence. ## **Error: sequence-construction initializer expression expected to have type '_type_' (instead got '_type_')_hint_** + ```dafny const s := seq(10, 20) ``` @@ -423,6 +425,7 @@ corresponding to their unicode value. ## **Error: type conversion to a real-based type is allowed only from numeric and bitvector types, char, and ORDINAL (got _type_)** + ```dafny const x: real := true as real ``` @@ -466,7 +469,7 @@ Not all pairs of types have implicit or even explicit conversions. But there are to the ORDINAL type from numeric types. Even `char` values have an integer representation and ORDINAL value corresponding to their unicode value. -## **Error: type cast to reference type '_type_' must be from an expression assignable to it (got '_type_')** +## **Error: type cast to reference type '_type_' must be from an expression of a compatible type (got '_type_')** ```dafny method m(i: int) { @@ -478,7 +481,7 @@ The Dafny `as` is a type cast. But Dafny only allows such casts (or checks with be cast from one to the other. In this case, something that is not a reference type is attempting to be cast to a type that is a reference type. -## **Error: type conversions are not supported to this type (got _type_)** +## **Error: type cast to type '_type_' must be from an expression of a compatible type (got '_type_')** ```dafny datatype D = A | B @@ -507,6 +510,7 @@ a datatype type is not allowed. ## **Error: first argument to _op_ must be of type bool (instead got _type_)** + ```dafny const b := true const i := 4 @@ -518,6 +522,7 @@ Dafny does not have any implicit conversion to or from `bool` values. ## **Error: second argument to _op_ must be of type bool (instead got _type_)** + ```dafny const b := true const i := 4 @@ -529,6 +534,7 @@ Dafny does not have any implicit conversion to or from `bool` values. ## **Error: range of quantified variable must be of type bool (instead got _type_)** + ```dafny function f(i: set): set { set k: int <- i | true || k } ``` @@ -540,6 +546,7 @@ when it is not a `bool`, this error message occurs. ## **Error: arguments must have comparable types (got _type_ and _type_)** + ```dafny datatype D = D() const z := 0 == D() @@ -600,7 +607,7 @@ For example, two different int-based subtypes would be converted to int, or two classes that extend the same trait could be converted to values of that trait. Where Dafny cannot determine such a common supertype, the comparison is illegal and this error message results. -## **Error: arguments to _op_ must be of a numeric type, bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got _type_ and _type_)** +## **Error: arguments to _op_ must be of a numeric type, bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got _type_)** ```dafny const x: map @@ -614,7 +621,7 @@ But they are not used for comparing maps or reference values. -## **Error: type of _op_ must be a bitvector type (instead got _type_)** +## **Error: type of _op_ must be of a bitvector type (instead got _type_)** ```dafny const z := 0 << 1 @@ -655,6 +662,7 @@ But not for all types. There is no `+` for datatypes or references, for example. ## **Error: type of left argument to + (_type_) must agree with the result type (_type_)** + ```dafny const z := 0 + {1} ``` @@ -673,7 +681,7 @@ Though the `+` operand applies to many of Dafny's types, the left- and right- op the same type or convertible to the same type. For example, there is no conversion from a type to a collection of that type. -## **Error: type of - must be of a numeric type, bitvector type, ORDINAL, char, or a set-like or map-like type (instead got _type_)** +## **Error: type of - must be of a numeric type, a bitvector type, ORDINAL, char, or a set-like or map-like type (instead got _type_)** ```dafny datatype D = D() @@ -687,6 +695,7 @@ But not for all types. There is no `-` for datatypes or references, for example. ## **Error: type of left argument to - (_type_) must agree with the result type (_type_)** + ```dafny const z := 0 - {1} ``` @@ -738,7 +747,7 @@ Typically the result of the expression is determined by the left operand. This message then is stating that the right operand has a different type. -## **Error: second argument to _op_ must be a set, multiset, or sequence with elements of type _type_, or a map with domain _type_ (instead got _type_)** +## **Error: second argument to _op_ must be a set, a multiset, a sequence with elements of type int, or a map with domain int (instead got _type_)** ```dafny function ff(i: int, j: real): bool { i in j } @@ -751,6 +760,7 @@ is deprecated in favor of `i in m.Keys`, ## **Error: domain of quantified variable must be a set, multiset, or sequence with elements of type _type_, or a map with domain _type_ (instead got _type_)** + ```dafny function f(i: int): set { set k <- i | k } ```