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

Fix crash in type checking of nested field assign lhs #782

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 1 deletion Source/Core/AST/AbsyCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,9 +2362,10 @@ public override void Resolve(ResolutionContext rc)

public override void Typecheck(TypecheckingContext tc)
{
var errorCount = tc.ErrorCount;
Datatype.Typecheck(tc);
TypeParameters = SimpleTypeParamInstantiation.EMPTY;
if (Datatype.Type != null)
if (tc.ErrorCount == errorCount)
{
TypeAttr = FieldAccess.Typecheck(Datatype.Type, tc, out TypeParameters);
}
Expand Down
27 changes: 27 additions & 0 deletions Test/datatypes/unknown_field_error.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %parallel-boogie /lib:base "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

type MemAddr;
type CacheId;

datatype DirState {
Owner(i: CacheId),
Sharers(i: CacheId)
}

datatype DirRequest {
Share(i: CacheId),
Own(i: CacheId)
}

datatype DirInfo {
DirInfo(state: DirState, pending: DirRequest)
}

var dir: [MemAddr]DirInfo;

procedure cache_snoop_resp(i: CacheId, ma: MemAddr)
modifies dir;
{
dir[ma]->t->pending := dir[ma]->t->pending;
}
3 changes: 3 additions & 0 deletions Test/datatypes/unknown_field_error.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
unknown_field_error.bpl(26,11): Error: datatype DirInfo does not have a field with name t
unknown_field_error.bpl(26,34): Error: datatype DirInfo does not have a field with name t
2 type checking errors detected in unknown_field_error.bpl
Loading