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

No nesting inside RangeToken.StartToken #5976

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3b0d5b0
Renamed RangeToken to Origin
keyboardDrummer Dec 11, 2024
fa32c04
Rename a few methods in Cloner
keyboardDrummer Dec 11, 2024
c6ba51a
Move TokenNode to separate class
keyboardDrummer Dec 11, 2024
c251ca7
Move RangeNode to separate class
keyboardDrummer Dec 11, 2024
74239df
Finish renaming methods in cloner
keyboardDrummer Dec 11, 2024
1fea23c
Use Origin type where RangeToken is used
keyboardDrummer Dec 11, 2024
a9fa050
Ran formatter
keyboardDrummer Dec 11, 2024
4ccd1cf
Finish renaming cloner methods
keyboardDrummer Dec 11, 2024
6977d60
Parser part of rename RangeToken property to Origin
keyboardDrummer Dec 11, 2024
2e43fe1
Use Origin type where RangeToken is used
keyboardDrummer Dec 11, 2024
b42c005
Install .NET in runtime-tests.yml
keyboardDrummer Dec 11, 2024
693167f
Install dotnet 8.x.x
keyboardDrummer Dec 11, 2024
9cb039b
Do not require .NET 8 CLI
keyboardDrummer Dec 11, 2024
9b19a50
Another try
keyboardDrummer Dec 11, 2024
68b85c8
Bring back old global.json
keyboardDrummer Dec 11, 2024
2313267
Install additional .NET sdk
keyboardDrummer Dec 11, 2024
5574427
Install 8.0.x for doc-tests.yml as well
keyboardDrummer Dec 11, 2024
0e659cc
Add documentation
keyboardDrummer Dec 11, 2024
2aecde0
Merge branch 'renameRangeTokenToOrigin' into useOriginTypeWhereRangeT…
keyboardDrummer Dec 12, 2024
41998b4
Merge commit '579df1688d0925' into useOriginTypeWhereRangeTokenIsUsed
keyboardDrummer Dec 12, 2024
39b1b2b
Only let RangeToken take tokens as arguments
keyboardDrummer Dec 12, 2024
f6e956a
Remove Center property
keyboardDrummer Dec 12, 2024
8e774cf
Fixes
keyboardDrummer Dec 12, 2024
1aed335
Fixes
keyboardDrummer Dec 12, 2024
7dc063c
Fix
keyboardDrummer Dec 12, 2024
9e23003
Let variables carry a Name node
keyboardDrummer Dec 12, 2024
b4b498b
Fix
keyboardDrummer Dec 12, 2024
3e405e7
Ran formatter
keyboardDrummer Dec 12, 2024
d4d9d1d
Correct definition and use of IncludesRange
keyboardDrummer Dec 12, 2024
96a39c6
Fix bug in override of .Tok
keyboardDrummer Dec 12, 2024
a72965c
Replace unwrapping with a virtual method to determine if a token is i…
keyboardDrummer Dec 12, 2024
e97b51f
Fix override of .Tok
keyboardDrummer Dec 12, 2024
15cba87
Fix expect file
keyboardDrummer Dec 12, 2024
c728f02
Fixes
keyboardDrummer Dec 12, 2024
c0b0028
Fix
keyboardDrummer Dec 12, 2024
1f44b75
Merge branch 'master' into noNestingInsideRangeToken
keyboardDrummer Dec 12, 2024
4a60427
Merge branch 'master' into noNestingInsideRangeToken
keyboardDrummer Dec 13, 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
2 changes: 1 addition & 1 deletion Source/DafnyCore.Test/ClonerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DummyDecl : Declaration {
public DummyDecl(Cloner cloner, Declaration original) : base(cloner, original) {
}

public DummyDecl(RangeToken rangeOrigin, Name name, Attributes attributes, bool isRefining) : base(rangeOrigin, name,
public DummyDecl(IOrigin rangeOrigin, Name name, Attributes attributes, bool isRefining) : base(rangeOrigin, name,
attributes, isRefining) {
}

Expand Down
4 changes: 2 additions & 2 deletions Source/DafnyCore.Test/NodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace DafnyCore.Test;
public class NodeTests {

class ConcreteNode : Node {
public ConcreteNode(RangeToken rangeOrigin, IEnumerable<INode>? children = null) {
public ConcreteNode(IOrigin rangeOrigin, IEnumerable<INode>? children = null) {
Origin = rangeOrigin;
Children = children ?? Enumerable.Empty<INode>();
}

public override RangeToken Origin { get; set; }
public override IOrigin Origin { get; set; }
public override IOrigin Tok => Origin.StartToken;
public override IEnumerable<INode> Children { get; }
public override IEnumerable<INode> PreResolveChildren => Children;
Expand Down
11 changes: 4 additions & 7 deletions Source/DafnyCore/AST/Cloner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public virtual Type CloneType(Type t) {
public virtual Formal CloneFormal(Formal formal, bool isReference) {
return (Formal)clones.GetOrCreate(formal, () => isReference
? formal
: new Formal(Origin(formal.tok), formal.Name, CloneType(formal.Type), formal.InParam, formal.IsGhost,
: new Formal(Origin(formal.tok), new Name(this, formal.NameNode), CloneType(formal.Type), formal.InParam, formal.IsGhost,
CloneExpr(formal.DefaultValue), CloneAttributes(formal.Attributes),
formal.IsOld, formal.IsNameOnly, formal.IsOlder, formal.NameForCompilation) {
Origin = formal.Origin,
Expand All @@ -283,7 +283,7 @@ public virtual BoundVar CloneBoundVar(BoundVar bv, bool isReference) {
return bv;
}

var bvNew = new BoundVar(Origin(bv.tok), bv.Name, CloneType(bv.SyntacticType));
var bvNew = new BoundVar(Origin(bv.tok), new Name(this, bv.NameNode), CloneType(bv.SyntacticType));
bvNew.IsGhost = bv.IsGhost;
return bvNew;
});
Expand Down Expand Up @@ -596,14 +596,11 @@ public virtual BlockStmt CloneMethodBody(Method m) {
}
}

public virtual RangeToken Origin(RangeToken range) {
if (range == null) {
public virtual IOrigin Origin(IOrigin tok) {
if (tok == null) {
return null;
}
return new RangeToken(Origin(range.StartToken), Origin(range.EndToken));
}

public virtual IOrigin Origin(IOrigin tok) {
Contract.Requires(tok != null);
return tok;
}
Expand Down
6 changes: 3 additions & 3 deletions Source/DafnyCore/AST/Expressions/Applications/ApplyExpr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public override IEnumerable<Expression> SubExpressions {
}
}

public IOrigin CloseParen;
public Token CloseParen;

public ApplyExpr(Cloner cloner, ApplyExpr original) : base(cloner, original) {
Function = cloner.CloneExpr(original.Function);
Args = original.Args.ConvertAll(cloner.CloneExpr);
CloseParen = cloner.Origin(original.CloseParen);
CloseParen = original.CloseParen;
}

public ApplyExpr(IOrigin tok, Expression fn, List<Expression> args, IOrigin closeParen)
public ApplyExpr(IOrigin tok, Expression fn, List<Expression> args, Token closeParen)
: base(tok) {
Function = fn;
Args = args;
Expand Down
8 changes: 4 additions & 4 deletions Source/DafnyCore/AST/Expressions/Applications/ApplySuffix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Dafny;
/// </summary>
public class ApplySuffix : SuffixExpr, ICloneable<ApplySuffix>, ICanFormat {
public readonly IOrigin/*?*/ AtTok;
public readonly IOrigin CloseParen;
public readonly Token CloseParen;
public readonly ActualBindings Bindings;
public List<Expression> Args => Bindings.Arguments;
[FilledInDuringResolution] public MethodCallInformation MethodCallInfo = null; // resolution will set to a non-null value if ApplySuffix makes a method call
Expand All @@ -30,12 +30,12 @@ public ApplySuffix Clone(Cloner cloner) {
public ApplySuffix(Cloner cloner, ApplySuffix original) :
base(cloner, original) {
AtTok = original.AtTok == null ? null : cloner.Origin(original.AtTok);
CloseParen = cloner.Origin(original.CloseParen);
CloseParen = original.CloseParen;
FormatTokens = original.FormatTokens;
Bindings = new ActualBindings(cloner, original.Bindings);
}

public ApplySuffix(IOrigin tok, IOrigin/*?*/ atLabel, Expression lhs, List<ActualBinding> args, IOrigin closeParen)
public ApplySuffix(IOrigin tok, IOrigin/*?*/ atLabel, Expression lhs, List<ActualBinding> args, Token closeParen)
: base(tok, lhs) {
Contract.Requires(tok != null);
Contract.Requires(lhs != null);
Expand Down Expand Up @@ -69,7 +69,7 @@ public override IEnumerable<Expression> PreResolveSubExpressions {
public static Expression MakeRawApplySuffix(IOrigin tok, string name, List<Expression> args) {
var nameExpr = new NameSegment(tok, name, null);
var argBindings = args.ConvertAll(arg => new ActualBinding(null, arg));
return new ApplySuffix(tok, null, nameExpr, argBindings, tok);
return new ApplySuffix(tok, null, nameExpr, argBindings, Token.NoToken);
}

public bool SetIndent(int indentBefore, TokenNewIndentCollector formatter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class FunctionCallExpr : Expression, IHasReferences, ICloneable<FunctionC
public string Name;
public readonly Expression Receiver;
public readonly IOrigin OpenParen; // can be null if Args.Count == 0
public readonly IOrigin CloseParen;
public readonly Token CloseParen;
public readonly Label/*?*/ AtLabel;
public readonly ActualBindings Bindings;
public List<Expression> Args => Bindings.Arguments;
Expand Down Expand Up @@ -74,7 +74,7 @@ void ObjectInvariant() {

[FilledInDuringResolution] public Function Function;

public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin openParen, IOrigin closeParen, [Captured] List<ActualBinding> args, Label/*?*/ atLabel = null)
public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin openParen, Token closeParen, [Captured] List<ActualBinding> args, Label/*?*/ atLabel = null)
: this(tok, fn, receiver, openParen, closeParen, new ActualBindings(args), atLabel) {
Contract.Requires(tok != null);
Contract.Requires(fn != null);
Expand All @@ -84,7 +84,7 @@ public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin ope
Contract.Ensures(type == null);
}

public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin openParen, IOrigin closeParen, [Captured] ActualBindings bindings, Label/*?*/ atLabel = null)
public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin openParen, Token closeParen, [Captured] ActualBindings bindings, Label/*?*/ atLabel = null)
: base(tok) {
Contract.Requires(tok != null);
Contract.Requires(fn != null);
Expand All @@ -106,7 +106,7 @@ public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin ope
/// This constructor is intended to be used when constructing a resolved FunctionCallExpr. The "args" are expected
/// to be already resolved, and are all given positionally.
/// </summary>
public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin openParen, IOrigin closeParen, [Captured] List<Expression> args,
public FunctionCallExpr(IOrigin tok, string fn, Expression receiver, IOrigin openParen, Token closeParen, [Captured] List<Expression> args,
Label /*?*/ atLabel = null)
: this(tok, fn, receiver, openParen, closeParen, args.ConvertAll(e => new ActualBinding(null, e)), atLabel) {
Bindings.AcceptArgumentExpressionsAsExactParameterList();
Expand All @@ -120,7 +120,7 @@ public FunctionCallExpr(Cloner cloner, FunctionCallExpr original) : base(cloner,
Name = original.Name;
Receiver = cloner.CloneExpr(original.Receiver);
OpenParen = original.OpenParen == null ? null : cloner.Origin(original.OpenParen);
CloseParen = original.CloseParen == null ? null : cloner.Origin(original.CloseParen);
CloseParen = original.CloseParen;
Bindings = new ActualBindings(cloner, original.Bindings);
AtLabel = original.AtLabel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public class SeqSelectExpr : Expression, ICloneable<SeqSelectExpr> {
public readonly Expression Seq;
public readonly Expression E0;
public readonly Expression E1;
public readonly IOrigin CloseParen;
public readonly Token CloseParen;

public SeqSelectExpr(Cloner cloner, SeqSelectExpr original) : base(cloner, original) {
SelectOne = original.SelectOne;
Seq = cloner.CloneExpr(original.Seq);
E0 = cloner.CloneExpr(original.E0);
E1 = cloner.CloneExpr(original.E1);
CloseParen = cloner.Origin(original.CloseParen);
CloseParen = original.CloseParen;
}

[ContractInvariantMethod]
Expand All @@ -24,7 +24,7 @@ void ObjectInvariant() {
Contract.Invariant(!SelectOne || E1 == null);
}

public SeqSelectExpr(IOrigin tok, bool selectOne, Expression seq, Expression e0, Expression e1, IOrigin closeParen)
public SeqSelectExpr(IOrigin tok, bool selectOne, Expression seq, Expression e0, Expression e1, Token closeParen)
: base(tok) {
Contract.Requires(tok != null);
Contract.Requires(seq != null);
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/AST/Expressions/AttributedExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Attributes Attributes {

string IAttributeBearingDeclaration.WhatKind => "expression";

public override RangeToken Origin => E.Origin;
public override IOrigin Origin => E.Origin;

public bool HasAttributes() {
return Attributes != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<BoundVar> UncompilableBoundVars() {
return BoundedPool.MissingBounds(BoundVars, Bounds, v);
}

public ComprehensionExpr(IOrigin tok, RangeToken rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
public ComprehensionExpr(IOrigin tok, IOrigin rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
: base(tok) {
Contract.Requires(tok != null);
Contract.Requires(cce.NonNullElements(bvars));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ExistsExpr : QuantifierExpr, ICloneable<ExistsExpr> {
public override string WhatKind => "exists expression";
protected override BinaryExpr.ResolvedOpcode SplitResolvedOp { get { return BinaryExpr.ResolvedOpcode.Or; } }

public ExistsExpr(IOrigin tok, RangeToken rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
public ExistsExpr(IOrigin tok, IOrigin rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
: base(tok, rangeOrigin, bvars, range, term, attrs) {
Contract.Requires(cce.NonNullElements(bvars));
Contract.Requires(tok != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ForallExpr : QuantifierExpr, ICloneable<ForallExpr> {
public override string WhatKind => "forall expression";
protected override BinaryExpr.ResolvedOpcode SplitResolvedOp => BinaryExpr.ResolvedOpcode.And;

public ForallExpr(IOrigin tok, RangeToken rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
public ForallExpr(IOrigin tok, IOrigin rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
: base(tok, rangeOrigin, bvars, range, term, attrs) {
Contract.Requires(cce.NonNullElements(bvars));
Contract.Requires(tok != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class LambdaExpr : ComprehensionExpr, ICloneable<LambdaExpr>, IFrameScope

public readonly Specification<FrameExpression> Reads;

public LambdaExpr(IOrigin tok, RangeToken rangeOrigin, List<BoundVar> bvars, Expression requires, Specification<FrameExpression> reads, Expression body)
public LambdaExpr(IOrigin tok, IOrigin rangeOrigin, List<BoundVar> bvars, Expression requires, Specification<FrameExpression> reads, Expression body)
: base(tok, rangeOrigin, bvars, requires, body, null) {
Contract.Requires(reads != null);
Reads = reads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MapComprehension(Cloner cloner, MapComprehension original) : base(cloner,
Finite = original.Finite;
}

public MapComprehension(IOrigin tok, RangeToken rangeOrigin, bool finite, List<BoundVar> bvars, Expression range, Expression/*?*/ termLeft, Expression termRight, Attributes attrs)
public MapComprehension(IOrigin tok, IOrigin rangeOrigin, bool finite, List<BoundVar> bvars, Expression range, Expression/*?*/ termLeft, Expression termRight, Attributes attrs)
: base(tok, rangeOrigin, bvars, range, termRight, attrs) {
Contract.Requires(tok != null);
Contract.Requires(cce.NonNullElements(bvars));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String Refresh(string prefix, FreshIdGenerator idGen) {
return idGen.FreshId(prefix);
}

public QuantifierExpr(IOrigin tok, RangeToken rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
public QuantifierExpr(IOrigin tok, IOrigin rangeOrigin, List<BoundVar> bvars, Expression range, Expression term, Attributes attrs)
: base(tok, rangeOrigin, bvars, range, term, attrs) {
Contract.Requires(tok != null);
Contract.Requires(cce.NonNullElements(bvars));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public SetComprehension(Cloner cloner, SetComprehension original) : base(cloner,
Finite = original.Finite;
}

public SetComprehension(IOrigin tok, RangeToken rangeOrigin, bool finite, List<BoundVar> bvars, Expression range, Expression/*?*/ term, Attributes attrs)
public SetComprehension(IOrigin tok, IOrigin rangeOrigin, bool finite, List<BoundVar> bvars, Expression range, Expression/*?*/ term, Attributes attrs)
: base(tok, rangeOrigin, bvars, range, term ?? new IdentifierExpr(tok, bvars[0].Name), attrs) {
Contract.Requires(tok != null);
Contract.Requires(cce.NonNullElements(bvars));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class NestedMatchCaseStmt : NestedMatchCase, IAttributeBearingDeclaration
public readonly List<Statement> Body;
public Attributes Attributes { get; set; }
string IAttributeBearingDeclaration.WhatKind => "match statement case";
public NestedMatchCaseStmt(RangeToken rangeOrigin, ExtendedPattern pat, List<Statement> body) : base(rangeOrigin.StartToken, pat) {
public NestedMatchCaseStmt(IOrigin rangeOrigin, ExtendedPattern pat, List<Statement> body) : base(rangeOrigin.StartToken, pat) {
Origin = rangeOrigin;
Contract.Requires(body != null);
this.Body = body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override IEnumerable<Expression> NonSpecificationSubExpressions {
}
}

public NestedMatchStmt(RangeToken rangeOrigin, Expression source, [Captured] List<NestedMatchCaseStmt> cases, bool usesOptionalBraces, Attributes attrs = null)
public NestedMatchStmt(IOrigin rangeOrigin, Expression source, [Captured] List<NestedMatchCaseStmt> cases, bool usesOptionalBraces, Attributes attrs = null)
: base(rangeOrigin, attrs) {
Contract.Requires(source != null);
Contract.Requires(cce.NonNullElements(cases));
Expand Down
1 change: 0 additions & 1 deletion Source/DafnyCore/AST/Expressions/DefaultValueExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ protected DefaultValueExpression(IOrigin tok, Formal formal, Expression/*?*/ rec
this.formal = formal;
this.receiver = receiver;
this.substMap = substMap;
Origin = new RangeToken(tok, tok);
}

protected DefaultValueExpression(Cloner cloner, DefaultValueExpression original) : base(cloner, original) {
Expand Down
4 changes: 2 additions & 2 deletions Source/DafnyCore/AST/Expressions/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public static Expression CreateResolvedCall(IOrigin tok, Expression receiver, Fu
Contract.Requires(function.Ins.Count == arguments.Count);
Contract.Requires(function.TypeArgs.Count == typeArguments.Count);

var call = new FunctionCallExpr(tok, function.Name, receiver, tok, tok, arguments) {
var call = new FunctionCallExpr(tok, function.Name, receiver, tok, Token.NoToken, arguments) {
Function = function,
Type = function.ResultType,
TypeApplication_AtEnclosingClass = receiver.Type.TypeArgs,
Expand All @@ -775,7 +775,7 @@ public static Expression WrapResolvedCall(FunctionCallExpr call, SystemModuleMan
};

subst = TypeParameter.SubstitutionMap(call.Function.TypeArgs, call.TypeApplication_JustFunction);
return new ApplySuffix(call.tok, null, exprDotName, new ActualBindings(call.Args).ArgumentBindings, call.tok) {
return new ApplySuffix(call.tok, null, exprDotName, new ActualBindings(call.Args).ArgumentBindings, call.CloseParen) {
ResolvedExpression = call,
Type = call.Function.ResultType.Subst(subst)
};
Expand Down
14 changes: 13 additions & 1 deletion Source/DafnyCore/AST/Expressions/Variables/BoundVar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ namespace Microsoft.Dafny;
[DebuggerDisplay("Bound<{name}>")]
public class BoundVar : NonglobalVariable {
public override bool IsMutable => false;
public BoundVar(IOrigin tok, string name, Type type)

public BoundVar(string name, Type type) : this(Token.NoToken, new Name(Token.NoToken, name), type) { }
public BoundVar(IOrigin origin, string name, Type type) : this(origin, new Name(origin.StartToken, name), type) { }

public BoundVar(IOrigin tok, Name name, Type type)
: base(tok, name, type, false) {
Contract.Requires(tok != null);
Contract.Requires(name != null);
Expand Down Expand Up @@ -86,6 +90,10 @@ class QuantifiedVariableDomainCloner : Cloner {
public static readonly QuantifiedVariableDomainCloner Instance = new QuantifiedVariableDomainCloner();
private QuantifiedVariableDomainCloner() { }
public override IOrigin Origin(IOrigin tok) {
if (tok == null) {
return null;
}

return new QuantifiedVariableDomainOrigin(tok);
}
}
Expand All @@ -94,6 +102,10 @@ class QuantifiedVariableRangeCloner : Cloner {
public static readonly QuantifiedVariableRangeCloner Instance = new QuantifiedVariableRangeCloner();
private QuantifiedVariableRangeCloner() { }
public override IOrigin Origin(IOrigin tok) {
if (tok == null) {
return null;
}

return new QuantifiedVariableRangeOrigin(tok);
}
}
15 changes: 11 additions & 4 deletions Source/DafnyCore/AST/Expressions/Variables/Formal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@ public class Formal : NonglobalVariable {
public Formal(IOrigin tok, string name, Type type, bool inParam, bool isGhost, Expression defaultValue,
Attributes attributes = null,
bool isOld = false, bool isNameOnly = false, bool isOlder = false, string nameForCompilation = null)
: base(tok, name, type, isGhost) {
: this(tok, new Name(tok.StartToken, name), type, inParam, isGhost, defaultValue, attributes,
isOld, isNameOnly, isOlder, nameForCompilation) {
}

public Formal(IOrigin tok, Name nameNode, Type type, bool inParam, bool isGhost, Expression defaultValue,
Attributes attributes = null,
bool isOld = false, bool isNameOnly = false, bool isOlder = false, string nameForCompilation = null)
: base(tok, nameNode, type, isGhost) {
Contract.Requires(tok != null);
Contract.Requires(name != null);
Contract.Requires(nameNode != null);
Contract.Requires(type != null);
Contract.Requires(inParam || defaultValue == null);
Contract.Requires(!isNameOnly || (inParam && !name.StartsWith("#")));
Contract.Requires(!isNameOnly || (inParam && !nameNode.Value.StartsWith("#")));
InParam = inParam;
IsOld = isOld;
DefaultValue = defaultValue;
Attributes = attributes;
IsNameOnly = isNameOnly;
IsOlder = isOlder;
NameForCompilation = nameForCompilation ?? name;
NameForCompilation = nameForCompilation ?? nameNode.Value;
}

public bool HasName => !Name.StartsWith("#");
Expand Down
Loading
Loading