Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 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
68d8dda
Merge branch 'master' into refresh-by-default
RustanLeino Oct 31, 2024
d048c19
Fix parameter resolution
RustanLeino Oct 31, 2024
29353b8
Merge branch 'master' into refresh-by-default
RustanLeino Nov 1, 2024
5e1d3c7
Improve code
RustanLeino Nov 1, 2024
8d69f48
Merge branch 'master' into refresh-by-default
RustanLeino Nov 1, 2024
3b1eb8f
Remove deprecated semi-colons
RustanLeino Nov 1, 2024
b4dc9a4
Update tests
RustanLeino Nov 2, 2024
d90e117
chore: Clean up code
RustanLeino Nov 2, 2024
2c0142d
Fix case where all candidate ctors are ghost
RustanLeino Nov 2, 2024
31af1c2
Fix output
RustanLeino Nov 2, 2024
dcc4ce1
Set .PreType even when DatatypeValue is in error
RustanLeino Nov 2, 2024
717288f
chore: Clean up code and comment
RustanLeino Nov 2, 2024
7b2f342
Forget duplicate destructor names
RustanLeino Nov 2, 2024
d9a5fbe
Merge branch 'master' into refresh-by-default
RustanLeino Nov 11, 2024
a4194d1
fix: Fix issue 2019 for new resolver
RustanLeino Nov 11, 2024
9c56002
Adjust test output
RustanLeino Nov 11, 2024
46721b7
Adjust tests and outputs
RustanLeino Nov 11, 2024
64bb5ac
Fix crash from illegal literal expression in case pattern
RustanLeino Nov 12, 2024
94cff6a
Update test to new type-conversion rules
RustanLeino Nov 12, 2024
c507770
Fix sed issue for the last last time!!
RustanLeino Nov 12, 2024
d56fe91
Improve test and error messages
RustanLeino Nov 12, 2024
2606e87
Adjust tests
RustanLeino Nov 12, 2024
8c6ef14
Clarify tests and don’t insist on having type for _
RustanLeino Nov 12, 2024
bd090f2
Update test answers
RustanLeino Nov 12, 2024
c04d7ee
Fix tests
RustanLeino Nov 12, 2024
ac82f59
Fix type checking of real division
RustanLeino Nov 12, 2024
7c90391
Fix type inference for string literals
RustanLeino Nov 12, 2024
62b36c2
chore: Improve code
RustanLeino Nov 12, 2024
c9b37e7
Make error message more consistent
RustanLeino Nov 12, 2024
d030c34
Fix type constraint checking on string literals
RustanLeino Nov 12, 2024
2f133bd
Improve error messages
RustanLeino Nov 13, 2024
7f74680
Improve error message
RustanLeino Nov 13, 2024
5cf5c0c
Merge branch 'master' into refresh-by-default
RustanLeino Nov 13, 2024
8fc1f58
Fix DatatypeValue type parameter, and fix tests
RustanLeino Nov 13, 2024
59a0849
Merge branch 'master' into refresh-by-default
RustanLeino Nov 13, 2024
18232fe
Remove variance parameter from PreType-to-Type process
RustanLeino Nov 15, 2024
1126c91
Update tests
RustanLeino Nov 15, 2024
f1f54ac
Merge branch 'master' into refresh-by-default
RustanLeino Nov 15, 2024
4aa3559
Merge branch 'master' into refresh-by-default
RustanLeino Dec 10, 2024
4d0aaeb
Adjust tests with improved type inference
RustanLeino Dec 14, 2024
8ab207d
Adjust tests with improved type inference
RustanLeino Dec 14, 2024
1f69ce8
Improve error message
RustanLeino Dec 17, 2024
c39c02e
Use old resolver for tests that need more work
RustanLeino Dec 17, 2024
ca3b1da
Say ‘string’ instead of ‘seq<char>’ for string literals
RustanLeino Dec 17, 2024
6efb5cd
Merge branch 'master' into refresh-by-default
RustanLeino Dec 18, 2024
f17aba5
Revert some tests back to explicitly using old resolver (for now)
RustanLeino Dec 19, 2024
5cc235e
Update AsIs expected output
RustanLeino Dec 23, 2024
8efb254
Add test case for Issue 2040, which has been fixed
RustanLeino Jan 2, 2025
6f59e17
Merge branch 'master' into refresh-by-default
RustanLeino Jan 2, 2025
0137d3d
Fix merge
RustanLeino Jan 2, 2025
14e69f6
Fix and add tests and adjust expected test output
RustanLeino Jan 3, 2025
b06cae7
Merge branch 'master' into refresh-by-default
RustanLeino Jan 4, 2025
9e72c35
Fix up tests and expected output
RustanLeino Jan 4, 2025
b03dbbd
Fix up tests and expected output
RustanLeino Jan 4, 2025
ade18b7
Merge branch 'master' into refresh-by-default
RustanLeino Jan 13, 2025
044fcb0
Update tests
RustanLeino Jan 13, 2025
78885b0
chore: Improve code formatting
RustanLeino Jan 14, 2025
1b7407d
chore: Simplify code (remove premature optimizations)
RustanLeino Jan 14, 2025
e51d4fe
fix: Apply function-call substitution in frame override check
RustanLeino Jan 14, 2025
b047c44
fix: Use correct type of “this” in allowance disjunct
RustanLeino Jan 14, 2025
5ba3a0b
Updated expected output
RustanLeino Jan 14, 2025
bf070b0
Cop-out: Mark failing test as legacy-resolver-only
RustanLeino Jan 14, 2025
e72c868
Merge branch 'master' into refresh-by-default
RustanLeino Jan 14, 2025
f6519a0
Cop-out: Mark failing test as legacy-resolver-only
RustanLeino Jan 14, 2025
71e78d4
Adjust tests
RustanLeino Jan 14, 2025
7acb9bd
Update HowToFAQ ID’s and expected output
RustanLeino Jan 14, 2025
3a2ad0e
Merge branch 'master' into refresh-by-default
RustanLeino Jan 14, 2025
7558275
Update HowToFAQ template
RustanLeino Jan 15, 2025
f0bf4f1
Merge branch 'master' into refresh-by-default
RustanLeino Jan 15, 2025
4e26996
Update some HowToFAQ resolver errors and punted on others
RustanLeino Jan 16, 2025
62c0a59
Fix test expectations
RustanLeino Jan 16, 2025
ec26b80
Add “extends object”
RustanLeino Jan 16, 2025
9d2aa89
Revert Rust tests to using old resolver
RustanLeino Jan 16, 2025
01ddf38
Fix Rust tests via lit on osx
RustanLeino Jan 16, 2025
322da9a
Revert Rust tests to use legacy traits
RustanLeino Jan 16, 2025
66767c6
Revert "Fix Rust tests via lit on osx"
RustanLeino Jan 16, 2025
0351fdb
chore: Improve C#
RustanLeino Jan 17, 2025
f06e2f4
Merge branch 'master' into refresh-by-default
RustanLeino Jan 17, 2025
19b602c
Merge branch 'master' into refresh-by-default
RustanLeino Feb 20, 2025
fe85f76
Merge branch 'master' into refresh-by-default
RustanLeino Feb 26, 2025
06b9c3e
Fix infinite loop
RustanLeino Feb 28, 2025
9c35e26
Update expect file
RustanLeino Feb 28, 2025
3658843
Merge branch 'master' into refresh-by-default
RustanLeino Feb 28, 2025
97c8dae
Leave DAFNY_INTEGRATION_TESTS_ONLY_COMPILERS name in file
RustanLeino Feb 28, 2025
b23bf05
chore: Improve C#
RustanLeino Mar 1, 2025
cbe8561
fix: Don’t use VarDecl in RHS of call statement
RustanLeino Mar 2, 2025
55d6ff6
chore: Improve C#
RustanLeino Mar 2, 2025
4e87a3d
fix: Resolve RHS attributes in the correct scope
RustanLeino Mar 2, 2025
076518f
Update trait declaration to use new type system
RustanLeino Mar 2, 2025
79567a9
Fix problem with using un-resolved sugared components
RustanLeino Mar 2, 2025
2c8373c
Update documentation to use new resolver
RustanLeino Mar 3, 2025
2579779
Address null warning
RustanLeino Mar 3, 2025
e38a6c1
Update Dafny-generated code
RustanLeino Mar 3, 2025
57d028e
fix: Adjust type of const’s
RustanLeino Mar 3, 2025
3ac95c9
fix: Fix type adjustments for SeqSelectExpr ranges
RustanLeino Mar 4, 2025
43c1239
Make types of bound variables explicit
RustanLeino Mar 4, 2025
d013a9a
Make StdLib types/verification go through
RustanLeino Mar 4, 2025
8ecb536
Add error for special opened-module case like in legacy resolver
RustanLeino Mar 4, 2025
b2c7df8
Update error messages in DafnyRef
RustanLeino Mar 4, 2025
e3b9087
Use new resolver with DafnyRuntimeDafny
RustanLeino Mar 4, 2025
f5bfa82
chore: Fix typo
RustanLeino Mar 4, 2025
50e0713
Explicitly use new resolver in StdLib build
RustanLeino Mar 4, 2025
d3a89c1
Update .doo files
RustanLeino Mar 4, 2025
c4f84d7
Merge branch 'master' into refresh-by-default
RustanLeino Mar 4, 2025
63980ab
Improve error messages involving types of functions
RustanLeino Mar 4, 2025
e46c6f6
Get StdLib examples to go through verification
RustanLeino Mar 4, 2025
931706c
Update test to use new
RustanLeino Mar 4, 2025
e5bc757
Use old resolver with test
RustanLeino Mar 4, 2025
64f938c
fix: Register StaticReceiverExpr as reference in lang.server
RustanLeino Mar 5, 2025
251c947
Adjust expect answer to new source range
RustanLeino Mar 5, 2025
7032a8a
fix: Remove duplicate error message
RustanLeino Mar 5, 2025
60840a3
Adjust expect error (no duplicate message)
RustanLeino Mar 6, 2025
2c6774f
chore: Avoid use of certain string literals
RustanLeino Mar 6, 2025
b38e94f
Rename folder to remove space
RustanLeino Mar 6, 2025
5c734df
Emit “extends object” for AutoExtern traits
RustanLeino Mar 6, 2025
af4d86e
Merge branch 'master' into refresh-by-default
RustanLeino Mar 6, 2025
c66646e
Explicitly use new resolver in lit tests
RustanLeino Mar 6, 2025
3fd152e
Revert default resolver to be the old one
RustanLeino Mar 6, 2025
bef9f91
Explicitly use new resolver for LanguageServer tests
RustanLeino Mar 7, 2025
94c12bf
Explicitly use new resolver in IntegrationTests
RustanLeino Mar 7, 2025
6589447
Explicitly use new resolve in Prelude generation
RustanLeino Mar 7, 2025
a975099
Explicitly use new resolver for DafnyGenerated code
RustanLeino Mar 7, 2025
36c2f30
Use %trargs and standardArguments with every use of %translate
RustanLeino Mar 7, 2025
52428fb
Also set general-(traits/newtypes) with testForEach(Resolver/Compiler)
RustanLeino Mar 7, 2025
9f2dc9a
Fix typo in option
RustanLeino Mar 7, 2025
17badf9
Split %translate/%trargs the same way as in lit.site.cfg
RustanLeino Mar 8, 2025
7ed588a
Remove redundant option
RustanLeino Mar 8, 2025
c60c7be
Improve RUN command
RustanLeino Mar 8, 2025
9dc943d
Add new-resolver arguments in a missing place
RustanLeino Mar 8, 2025
aa5d612
Fix audit tests and macros
RustanLeino Mar 8, 2025
1ddc176
Fix typo in new definition
RustanLeino Mar 9, 2025
c354a9e
Code review
keyboardDrummer Mar 10, 2025
54652be
Merge branch 'master' into refresh-by-default
keyboardDrummer Mar 10, 2025
780d883
Merge branch 'master' into refresh-by-default
RustanLeino Mar 14, 2025
c1831c3
Merge branch 'master' into refresh-by-default
RustanLeino Mar 18, 2025
3a679b4
Allow variation of error message in test output
RustanLeino Mar 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions Source/AutoExtern.Test/Minimal/Library.dfy.expect
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

trait {:compile false} {:extern} Intf {
trait {:compile false} {:extern} Intf extends object {
var {:extern "Prop"} Intf_Prop: System.String // interface property
}

trait {:compile false} {:extern} Impl extends Intf {
trait {:compile false} {:extern} Impl extends object, Intf {
var Field: System.int32
var Prop: System.String // property
}

trait {:compile false} {:extern} ICanClone<T> {
trait {:compile false} {:extern} ICanClone<T> extends object {
}

trait {:compile false} {:extern} Base {
trait {:compile false} {:extern} Base extends object {
}

trait {:compile false} {:extern} Derived {
trait {:compile false} {:extern} Derived extends object {
}

7 changes: 3 additions & 4 deletions Source/AutoExtern/AutoProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ protected void PpBlockOpen(TextWriter wr, string indent, object? kind, Name name
}
var paramsStr = parameters == null ? "" : $"<{String.Join(", ", parameters)}>";
parts.Add($"{name.AsDecl(forceExtern: true)}{paramsStr}");
if (inheritance != null) {
parts.Add($"extends {String.Join(", ", inheritance.Select(t => t.ToString()))}");
}
var parentTypes = inheritance == null ? "" : string.Concat(inheritance.Select(t => ", " + t.ToString()));
parts.Add("extends object" + parentTypes);
wr.WriteLine($"{indent}{String.Join(" ", parts)} {{");
}

Expand Down Expand Up @@ -519,7 +518,7 @@ public static int Main(string[] args) {

var skipInterfaceOption = new Option<List<string>>(
name: "--skip-interface",
description: "An interface to ommit from `extends` lists, e.g. `--skip-interface Microsoft.Dafny.ICloneable`.") {
description: "An interface to omit from `extends` lists, e.g. `--skip-interface Microsoft.Dafny.ICloneable`.") {
ArgumentHelpName = "interfaceName",
Arity = ArgumentArity.ZeroOrMore,
AllowMultipleArgumentsPerToken = false
Expand Down
3 changes: 3 additions & 0 deletions Source/DafnyCore/AST/Cloner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,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: 1 addition & 1 deletion Source/DafnyCore/AST/DafnyInterface.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module {:extern "Microsoft.Dafny"} MicrosoftDafny {
import opened System

@Compile(false)
trait {:extern "Token"} Token {
trait {:extern "Token"} Token extends object {
var val: CsString
var LeadingTrivia: CsString
var TrailingTrivia: CsString
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/AST/Expressions/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Type Type {

/// <summary>
/// The new type inference includes a "type refinement" phase, which determines the best subset types for a program. This phase works
/// by refining (mutating in the direction from bottom, meaning un ansatisfiable constraint, to top, meaning no constraint) types in place,
/// by refining (mutating in the direction from bottom, meaning an unsatisfiable constraint, to top, meaning no constraint) types in place,
/// using "TypeRefinementWrapper" type proxies. During that phase, it is necessary to obtain the
/// un-normalized type stored in each AST node, which is what the "UnnormalizedType" property does. This property should only be used
/// during the type refinement phase. After type inference is complete, use ".Type" instead.
Expand Down
12 changes: 3 additions & 9 deletions Source/DafnyCore/AST/Modules/ModuleDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,6 @@ public static IEnumerable<Field> AllFields(IEnumerable<TopLevelDecl> declaration
}
}

public static IEnumerable<TopLevelDeclWithMembers> AllTypesWithMembers(List<TopLevelDecl> declarations) {
foreach (var d in declarations) {
if (d is TopLevelDeclWithMembers cl) {
yield return cl;
}
}
}

/// <summary>
/// Yields all functions and methods that are members of some type in the given list of
/// declarations.
Expand Down Expand Up @@ -905,7 +897,9 @@ public ModuleSignature RegisterTopLevelDecls(ModuleResolver resolver, bool useIm
}
}

ctor.Destructors.Add(dtor);
if (!localDuplicate) {
ctor.Destructors.Add(dtor);
}
}

foreach (var duplicate in duplicates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class AssignOrReturnStmt : ConcreteAssignStatement, ICloneable<AssignOrRe

public override IEnumerable<Statement> PreResolveSubStatements => [];

public override IEnumerable<IdentifierExpr> GetAssignedLocals() {
return ResolvedStatements.SelectMany(r => r.GetAssignedLocals());
}

[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(Lhss != null);
Expand Down
4 changes: 4 additions & 0 deletions Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

public override IEnumerable<Statement> PreResolveSubStatements => [];

public override IEnumerable<IdentifierExpr> GetAssignedLocals() {
return ResolvedStatements.SelectMany(r => r.GetAssignedLocals());

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / build-refman (ubuntu-22.04)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / build-refman (ubuntu-22.04)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / singletons

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / singletons

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / singletons

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / singletons

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / ubuntu-20.04 (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / win (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / win (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / win (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / osx (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / osx (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / xunit-tests / osx (1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / integration-tests / test (ubuntu-20.04, 4)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / integration-tests / test (ubuntu-20.04, 3)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / integration-tests / test (ubuntu-20.04, 5)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / integration-tests / test (ubuntu-20.04, 2)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / integration-tests / test (ubuntu-20.04, 1)

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / doctests

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.

Check warning on line 28 in Source/DafnyCore/AST/Statements/Assignment/AssignStatement.cs

View workflow job for this annotation

GitHub Actions / doctests

Possible null reference argument for parameter 'source' in 'IEnumerable<IdentifierExpr> Enumerable.SelectMany<Statement, IdentifierExpr>(IEnumerable<Statement> source, Func<Statement, IEnumerable<IdentifierExpr>> selector)'.
}

[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(cce.NonNullElements(Lhss));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public override BoundedPool Clone(Cloner cloner) {
}
}

public override IEnumerable<IdentifierExpr> GetAssignedLocals() {
return Lhss.Select(lhs => lhs.Resolved).OfType<IdentifierExpr>();
}

public override IEnumerable<INode> Children => Lhss.Concat<Node>(new[] { Expr });

public AssignSuchThatStmt Clone(Cloner cloner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public ConcreteAssignStatement(IOrigin origin, List<Expression> lhss, Attributes

public override IEnumerable<INode> Children => Lhss;
public override IEnumerable<INode> PreResolveChildren => Lhss;
public override IEnumerable<IdentifierExpr> GetAssignedLocals() {
return Lhss.Select(lhs => lhs.Resolved).OfType<IdentifierExpr>();
}

public bool SetIndent(int indentBefore, TokenNewIndentCollector formatter) {
return formatter.SetIndentUpdateStmt(this, indentBefore, false);
Expand Down
5 changes: 4 additions & 1 deletion Source/DafnyCore/AST/Statements/Statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public virtual IEnumerable<Expression> NonSpecificationSubExpressions {
/// </summary>
public static Statement StripByBlocks(Statement stmt) {
while (stmt is BlockByProofStmt blockByProofStmt) {
stmt = blockByProofStmt;
stmt = blockByProofStmt.Body;
}
return stmt;
}
Expand Down Expand Up @@ -192,6 +192,9 @@ public override string ToString() {
Concat<Node>(
PreResolveSubStatements).Concat(PreResolveSubExpressions);

/// <summary>
/// GetAssignedLocals should only be called after successful resolution
/// </summary>
public virtual IEnumerable<IdentifierExpr> GetAssignedLocals() => [];


Expand Down
5 changes: 3 additions & 2 deletions Source/DafnyCore/AST/SystemModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public byte[] MyHash {
public readonly ISet<int> Bitwidths = new HashSet<int>();
[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, []); }
public readonly TraitDecl ObjectDecl;
Expand All @@ -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 ConcreteTypeSynonymDecl(SourceOrigin.NoToken, new Name("string"),
StringDecl = new ConcreteTypeSynonymDecl(SourceOrigin.NoToken, new Name("string"),
new TypeParameterCharacteristics(TypeParameter.EqualitySupportValue.InferredRequired, Type.AutoInitInfo.CompilableValue, false),
[], 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));
Expand Down
6 changes: 5 additions & 1 deletion Source/DafnyCore/AST/TypeDeclarations/Declaration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ void ObjectInvariant() {
public IOrigin BodyStartTok = Token.NoToken;
public Name NameNode;

public string GetNameRelativeToModule() {
return this is ICallable iCallable ? iCallable.NameRelativeToModule : ToString();
}

public virtual TokenRange NavigationRange => NameNode.ReportingRange;

public string Name => NameNode.Value;
Expand Down Expand Up @@ -174,4 +178,4 @@ public override string ToString() {

// For Compilation
internal CodeGenIdGenerator CodeGenIdGenerator = new();
}
}
3 changes: 2 additions & 1 deletion Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

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 @@ -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);
}
}

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 @@ -4265,7 +4265,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);
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4572,9 +4572,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 = ", ";
Expand Down Expand Up @@ -5350,7 +5350,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 = ", ";
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 @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/DafnyCore/DafnyGeneratedFromDafny.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ else
output="GeneratedFromDafny"
fi

../../Scripts/dafny translate cs dfyconfig.toml --output $output.cs $noverify
../../Scripts/dafny translate cs dfyconfig.toml --type-system-refresh --general-traits=datatype --general-newtypes --output $output.cs $noverify
# Exit with error code if the previous command fails
if [ $? -ne 0 ]; then
exit 1
fi

python3 DafnyGeneratedFromDafnyPost.py $output
python3 DafnyGeneratedFromDafnyPost.py $output
4 changes: 0 additions & 4 deletions Source/DafnyCore/DafnyMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,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
2 changes: 1 addition & 1 deletion Source/DafnyCore/GeneratedFromDafny/Formatting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static System.String ReindentProgramFromFirstToken(Microsoft.Dafny.Token
System.Text.StringBuilder _1_sb;
System.Text.StringBuilder _nw0 = new System.Text.StringBuilder();
_1_sb = _nw0;
while ((_0_token) != (object) ((Microsoft.Dafny.Token)null)) {
while ((_0_token) != (object) ((object)null)) {
System.String _2_newLeadingTrivia;
_2_newLeadingTrivia = (reindent).GetNewLeadingTrivia(_0_token);
System.String _3_newTrailingTrivia;
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/GeneratedFromDafny/RAST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ public RAST._IFields ReplaceFields(RAST._IFields fields) {
if (_source0.is_NamedFields) {
Dafny.ISequence<RAST._IField> _0_sFields = _source0.dtor_fields;
return RAST.Fields.create_NamedFields(Std.Collections.Seq.__default.Map<RAST._IField, RAST._IField>(((System.Func<RAST._IField, RAST._IField>)((_1_f) => {
return Dafny.Helpers.Let<RAST._IField, RAST._IField>(_1_f, _pat_let7_0 => Dafny.Helpers.Let<RAST._IField, RAST._IField>(_pat_let7_0, _2_dt__update__tmp_h0 => Dafny.Helpers.Let<RAST._IFormal, RAST._IField>(Dafny.Helpers.Let<RAST._IFormal, RAST._IFormal>((_1_f).dtor_formal, _pat_let9_0 => Dafny.Helpers.Let<RAST._IFormal, RAST._IFormal>(_pat_let9_0, _3_dt__update__tmp_h1 => Dafny.Helpers.Let<RAST._IType, RAST._IFormal>((this).ReplaceType(((_1_f).dtor_formal).dtor_tpe), _pat_let10_0 => Dafny.Helpers.Let<RAST._IType, RAST._IFormal>(_pat_let10_0, _4_dt__update_htpe_h0 => RAST.Formal.create((_3_dt__update__tmp_h1).dtor_name, _4_dt__update_htpe_h0))))), _pat_let8_0 => Dafny.Helpers.Let<RAST._IFormal, RAST._IField>(_pat_let8_0, _5_dt__update_hformal_h0 => RAST.Field.create((_2_dt__update__tmp_h0).dtor_visibility, _5_dt__update_hformal_h0)))));
return Dafny.Helpers.Let<RAST._IField, RAST._IField>(_1_f, _pat_let7_0 => Dafny.Helpers.Let<RAST._IField, RAST._IField>(_pat_let7_0, _2_dt__update__tmp_h1 => Dafny.Helpers.Let<RAST._IFormal, RAST._IField>(Dafny.Helpers.Let<RAST._IFormal, RAST._IFormal>((_1_f).dtor_formal, _pat_let9_0 => Dafny.Helpers.Let<RAST._IFormal, RAST._IFormal>(_pat_let9_0, _3_dt__update__tmp_h0 => Dafny.Helpers.Let<RAST._IType, RAST._IFormal>((this).ReplaceType(((_1_f).dtor_formal).dtor_tpe), _pat_let10_0 => Dafny.Helpers.Let<RAST._IType, RAST._IFormal>(_pat_let10_0, _4_dt__update_htpe_h0 => RAST.Formal.create((_3_dt__update__tmp_h0).dtor_name, _4_dt__update_htpe_h0))))), _pat_let8_0 => Dafny.Helpers.Let<RAST._IFormal, RAST._IField>(_pat_let8_0, _5_dt__update_hformal_h0 => RAST.Field.create((_2_dt__update__tmp_h1).dtor_visibility, _5_dt__update_hformal_h0)))));
})), _0_sFields));
}
}
Expand Down
22 changes: 15 additions & 7 deletions Source/DafnyCore/Generic/ErrorReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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) {
Expand Down Expand Up @@ -156,7 +156,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) {
Expand Down Expand Up @@ -196,7 +196,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));
}
}

Expand All @@ -206,14 +206,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, SourceOrigin tok, string msg) {
return $"{tok.OriginToString(Options)}: {header.ToString()}: {msg}";
}
}
}
Loading
Loading