Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use refresh resolver by default #5653

Draft
wants to merge 83 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
51e033a
Change default settings
RustanLeino May 28, 2024
5204eeb
Explicitly declare trait to be a reference type
RustanLeino May 28, 2024
3bdaa87
Make the new type system the default
keyboardDrummer Jun 27, 2024
48a8cf4
Merge branch 'master' into refresh-by-default
RustanLeino Jun 27, 2024
3101604
Explicitly declare trait as reference type
RustanLeino Jun 27, 2024
a134465
Changed from full to datatype
keyboardDrummer Jun 28, 2024
d75f39f
Add “extends object” where it was assumed to be so before
RustanLeino Jun 28, 2024
46484e6
Fix error location for desugared elephant assert
RustanLeino Jun 28, 2024
74a49df
Merge branch 'refresh-by-default' into typeSystemRefreshDefault
RustanLeino Jun 28, 2024
af730de
Merge branch 'master' into refresh-by-default
RustanLeino Jul 17, 2024
5acc14b
Use explicit legacy switches in testDafnyForEach…
RustanLeino Jul 18, 2024
611ac55
Fix missing box adjustment in verifier
RustanLeino Jul 18, 2024
4979a6e
fix: Use just one pre-type proxy for element type in array allocation
RustanLeino Jul 18, 2024
d701a33
Merge branch 'master' into refresh-by-default
RustanLeino Jul 30, 2024
7a5d171
Fix pre-type of StaticReceiverExpr
RustanLeino Aug 18, 2024
a4bf314
Update tests to support new defaults
RustanLeino Aug 20, 2024
18addcf
Involve compatible-type constraints in decision process
RustanLeino Aug 20, 2024
47d4abc
Update test
RustanLeino Aug 20, 2024
43a6a37
Extract method SansPrintablePreType
RustanLeino Aug 20, 2024
a6820e1
Fix type inference of seq/map/multiset update expressions
RustanLeino Aug 20, 2024
99fbb08
Merge branch 'master' into refresh-by-default
RustanLeino Aug 21, 2024
5026519
Fix asserted-expression output for frames
RustanLeino Aug 21, 2024
dab7870
Fix creation of yield-identifier expression
RustanLeino Aug 21, 2024
8028152
Update expect files
RustanLeino Aug 21, 2024
86e2312
Fix pre-type resolution of export-provided members/types
RustanLeino Aug 21, 2024
bb2d519
Improve formatting
RustanLeino Aug 21, 2024
d2624ee
Adjust tests and expected test output
RustanLeino Aug 21, 2024
456afc5
Fix parameter order
RustanLeino Aug 21, 2024
954dd42
Adjust tests and expected test output
RustanLeino Aug 22, 2024
3d617aa
Fix Boogie type of receiver in function-valued members
RustanLeino Aug 22, 2024
fbec421
chore: Improve code
RustanLeino Aug 22, 2024
6ec3676
Add tests
RustanLeino Aug 22, 2024
68ce112
fix: Pass in original (overridden) member
RustanLeino Aug 22, 2024
2d45cf6
Pass CLI parameter values explicitly
RustanLeino Aug 22, 2024
867a207
Prescribe type-refinement flows for SeqUpdateExpr
RustanLeino Aug 22, 2024
289a996
Add some temporary casts, waiting for flows to do more with bounded p…
RustanLeino Aug 22, 2024
785e4cc
Update tests and results
RustanLeino Aug 22, 2024
a442d33
Update tests and expected results
RustanLeino Aug 22, 2024
bddc2ce
Update tests and expected test output
RustanLeino Aug 22, 2024
cec4940
fix: Fix a printing crash
RustanLeino Aug 22, 2024
272bfe4
Update tests and expected output
RustanLeino Aug 23, 2024
35f4877
Update tests
RustanLeino Aug 23, 2024
a6bebff
Use basename for filename in %translate test
RustanLeino Aug 23, 2024
c44b7f8
Update test output
RustanLeino Aug 23, 2024
044d6e6
fix: Report error (and don’t crash) on disjunctive patterns inside ot…
RustanLeino Aug 23, 2024
f35922c
Expect errors for missing parentheses of non-nullary constructors in …
RustanLeino Aug 23, 2024
af98137
Move {:only} warnings from pass 0 to pass 3
RustanLeino Aug 23, 2024
8eadfea
Adjust tests and answers
RustanLeino Aug 23, 2024
2beb41f
Use nested comparable-types constraints as default advice
RustanLeino Aug 23, 2024
f9ca74e
fix: Subrange check and conversions to arrow types
RustanLeino Aug 24, 2024
be77ce8
Handle “as” for datatypes and arrows in compilers and verifier
RustanLeino Aug 24, 2024
8dcd806
Adjust tests
RustanLeino Aug 24, 2024
50c4987
Adjust tests and answers
RustanLeino Aug 24, 2024
d46da94
Adjust tests and outputs
RustanLeino Aug 24, 2024
138b341
Adjust tests and outputs
RustanLeino Aug 24, 2024
a73d698
fix: Support “assigned” in new resolver
RustanLeino Aug 24, 2024
bfb9100
Fill in missing case in type cloning
RustanLeino Aug 27, 2024
5cb67b9
fix: Print DecreasesToExpr with parentheses
RustanLeino Aug 28, 2024
2c3db7b
Don’t update RangeToken when resolving ParensExpression
RustanLeino Aug 28, 2024
b0739ec
Use sub/equal constraints to make type decisions
RustanLeino Aug 28, 2024
32a995a
Update improved (reduced) error messages
RustanLeino Aug 28, 2024
04be175
Update test and answers
RustanLeino Aug 28, 2024
c940168
Merge branch 'master' into refresh-by-default
RustanLeino Aug 28, 2024
e29ded6
Validate resolution CLI options (at a terrible place in the code)
RustanLeino Sep 3, 2024
16a91fe
Merge branch 'master' into refresh-by-default
RustanLeino Sep 3, 2024
5a7f699
Correct previous compensation
RustanLeino Sep 3, 2024
6bc0bab
Merge branch 'master' into refresh-by-default
RustanLeino Sep 4, 2024
8d83506
Fix test script for git-issue-321
RustanLeino Sep 4, 2024
110ff22
fix: Include case for BVNot
RustanLeino Sep 4, 2024
ba1b866
Adjust test outputs
RustanLeino Sep 4, 2024
e691271
Merge branch 'master' into refresh-by-default
RustanLeino Sep 5, 2024
4ba909c
Adjust tests
RustanLeino Sep 26, 2024
3dbd746
Adjust tests
RustanLeino Sep 26, 2024
737c57c
Start adjusting test
RustanLeino Sep 27, 2024
3b54b7e
Merge branch 'master' into refresh-by-default
RustanLeino Sep 27, 2024
27faf49
Merge branch 'master' into refresh-by-default
RustanLeino Oct 4, 2024
feeaa06
Adjust tests and answers
RustanLeino Oct 4, 2024
6652b68
Adjust tests and answers
RustanLeino Oct 5, 2024
006c8af
chore: Improve C#
RustanLeino Oct 5, 2024
ad77757
fix: Incorporate explicit type arguments for function calls and datat…
RustanLeino Oct 5, 2024
1a6ea55
Merge branch 'master' into refresh-by-default
RustanLeino Oct 7, 2024
a79a23e
Adjust tests
RustanLeino Oct 8, 2024
7466e28
Add “extends object” to tests
RustanLeino Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/DafnyCore/AST/Cloner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Source/DafnyCore/AST/Grammar/Printer/Printer.Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ void PrintExpr(Expression expr, int contextBindingStrength, bool fragileContext,
} else if (expr is Resolver_IdentifierExpr) {
wr.Write("[Resolver_IdentifierExpr]"); // we can get here in the middle of a debugging session
} else if (expr is DecreasesToExpr decreasesToExpr) {
wr.Write("(");
var comma = false;
foreach (var oldExpr in decreasesToExpr.OldExpressions) {
if (comma) {
Expand All @@ -1219,6 +1220,7 @@ void PrintExpr(Expression expr, int contextBindingStrength, bool fragileContext,
PrintExpression(newExpr, false);
comma = true;
}
wr.Write(")");
} else {
Contract.Assert(false); throw new cce.UnreachableException(); // unexpected expression
}
Expand Down
8 changes: 8 additions & 0 deletions Source/DafnyCore/AST/Modules/ModuleDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ public static IEnumerable<Field> AllFields(IEnumerable<TopLevelDecl> declaration
}
}

public static IEnumerable<MemberDecl> AllMembers(IEnumerable<TopLevelDecl> declarations) {
foreach (var decl in declarations.OfType<TopLevelDeclWithMembers>()) {
foreach (var member in decl.Members) {
yield return member;
}
}
}

public static IEnumerable<TopLevelDeclWithMembers> AllTypesWithMembers(List<TopLevelDecl> declarations) {
foreach (var d in declarations) {
if (d is TopLevelDeclWithMembers cl) {
Expand Down
3 changes: 2 additions & 1 deletion Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,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.tok, wr);
EmitExpr(fromExpr, inLetExprBody, wr, wStmts);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3767,7 +3767,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.tok, wr);
EmitExpr(fromExpr, inLetExprBody, wr, wStmts);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4293,7 +4293,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.tok, wr);
EmitExpr(fromExpr, inLetExprBody, wr, wStmts);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2462,7 +2462,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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4507,9 +4507,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.Tok, wr, toType);
var origToType = s.Method.Original.Ins[i].Type;
var instantiatedToType = origToType.Subst(s.MethodSelect.TypeArgumentSubstitutionsWithParents());
var w = EmitCoercionIfNecessary(fromType, instantiatedToType, s.Tok, wr, origToType);
w = EmitDowncastIfNecessary(fromType, instantiatedToType, s.Tok, w);
EmitExpr(s.Args[i], false, w, wStmts);
sep = ", ";
Expand Down Expand Up @@ -5287,7 +5287,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.tok, wr: wr, e.Function.Ins[i].Type);
var w = EmitCoercionIfNecessary(fromType, instantiatedToType, tok: e.tok, wr: wr, e.Function.Original.Ins[i].Type);
w = EmitDowncastIfNecessary(fromType, instantiatedToType, e.tok, w);
tr(e.Args[i], w, inLetExprBody, wStmts);
sep = ", ";
Expand Down
4 changes: 2 additions & 2 deletions Source/DafnyCore/CompileNestedMatch/MatchFlattener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,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.Tok, FreshTempVarName("_", null), null, p.IsGhost);
return new IdPattern(p.Tok, "_", null, p.IsGhost);
}
var args = p.Arguments?.ConvertAll(a => RemoveIllegalSubpatterns(a, inDisjunctivePattern));
return new IdPattern(p.Tok, p.Id, p.Type, args, p.IsGhost) { ResolvedLit = p.ResolvedLit, BoundVar = p.BoundVar };
case DisjunctivePattern p:
return new IdPattern(p.Tok, FreshTempVarName("_", null), null, p.IsGhost);
return new IdPattern(p.Tok, "_", null, p.IsGhost);
default:
Contract.Assert(false);
return null;
Expand Down
4 changes: 0 additions & 4 deletions Source/DafnyCore/DafnyMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,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();
Expand Down
26 changes: 17 additions & 9 deletions Source/DafnyCore/Generic/ErrorReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void Error(MessageSource source, Enum errorId, IToken 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, IToken tok, string msg) {
Expand Down Expand Up @@ -139,7 +139,7 @@ public void Warning(MessageSource source, Enum errorId, IToken tok, string forma
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, IToken tok, string msg) {
Expand Down Expand Up @@ -179,21 +179,29 @@ public void Deprecated(MessageSource source, Enum errorId, IToken tok, string fo
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));
}
}

public void Info(MessageSource source, IToken tok, string msg, object errorId = null) {
public void Info(MessageSource source, IToken tok, string format, object errorId = null) {
Contract.Requires(tok != null);
Contract.Requires(msg != null);
Message(source, ErrorLevel.Info, errorId?.ToString(), tok, msg);
Contract.Requires(format != null);
Message(source, ErrorLevel.Info, errorId?.ToString(), tok, format);
}

public void Info(MessageSource source, IToken tok, string msg, params object[] args) {
public void Info(MessageSource source, IToken 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, IToken tok, string msg) {
Expand Down
27 changes: 14 additions & 13 deletions Source/DafnyCore/Options/CommonOptionBag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ Note that quantifier variable domains (<- <Domain>) 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<bool> TypeSystemRefresh = new("--type-system-refresh", () => false,
public static readonly Option<bool> 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
};

Expand All @@ -221,18 +221,18 @@ public enum GeneralTraitsOptions {
Full
}

public static readonly Option<GeneralTraitsOptions> GeneralTraits = new("--general-traits", () => GeneralTraitsOptions.Legacy,
public static readonly Option<GeneralTraitsOptions> 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<bool> GeneralNewtypes = new("--general-newtypes", () => false,
public static readonly Option<bool> 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
};

Expand Down Expand Up @@ -414,15 +414,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);
Expand Down
16 changes: 16 additions & 0 deletions Source/DafnyCore/Resolver/ModuleResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,11 @@ public void ResolveTopLevelDecls_Core(List<TopLevelDecl> 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
Expand Down Expand Up @@ -1471,6 +1476,17 @@ public void ResolveTopLevelDecls_Core(List<TopLevelDecl> 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.RangeToken.ToToken(),
"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].RangeToken.ToToken(),
"{: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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2771,14 +2771,6 @@ void ResolveClassMemberBodies(TopLevelDeclWithMembers cl) {
currentClass = cl;
foreach (MemberDecl member in cl.Members) {
Contract.Assert(VisibleInScope(member));
if (member.HasUserAttribute("only", out var attribute)) {
reporter.Warning(MessageSource.Verifier, ResolutionErrors.ErrorId.r_member_only_assumes_other.ToString(), attribute.RangeToken.ToToken(),
"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].RangeToken.ToToken(),
"{:only} on members does not support arguments");
}
}
if (member is Field) {
var resolutionContext = new ResolutionContext(new NoContext(currentClass.EnclosingModuleDefinition), false);
scope.PushMarker();
Expand Down
12 changes: 11 additions & 1 deletion Source/DafnyCore/Resolver/PreType/PreType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,17 @@ public override PreType Substitute(Dictionary<TypeParameter, PreType> subst) {
return new DPreType(Decl, newArguments ?? Arguments, printablePreType);
}

public TopLevelDecl DeclWithMembersBypassInternalSynonym() {
if (Decl is InternalTypeSynonymDecl isyn) {
var udt = UserDefinedType.FromTopLevelDecl(isyn.tok, isyn);
if (isyn.RhsWithArgumentIgnoringScope(udt.TypeArgs) is UserDefinedType { ResolvedClass: { } decl }) {
return decl is NonNullTypeDecl nntd ? nntd.Class : decl;
}
}

return Decl;
}

/// <summary>
/// Returns the pre-type "parent<X>", where "X" is a list of type parameters that makes "parent<X>" a supertype of "this".
/// Requires "this" to be some pre-type "C<Y>" and "parent" to be among the reflexive, transitive parent traits of "C".
Expand All @@ -426,7 +437,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);
}

Expand Down
Loading
Loading