Skip to content

Commit

Permalink
Merge pull request #87 from ConsenSys/issues/85_86
Browse files Browse the repository at this point in the history
Fixes for #85 and #86
  • Loading branch information
cd1m0 authored Sep 30, 2021
2 parents ad72cf1 + 302a240 commit 6d11dc6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/instrumenter/state_vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ export function findAliasedStateVars(units: SourceUnit[]): Map<VariableDeclarati
return [rhs.vReferencedDeclaration as VariableDeclaration];
}

if (rhs instanceof Identifier) {
return [];
}

if (rhs instanceof MemberAccess) {
return gatherRHSVars(rhs.vExpression);
}
Expand Down
12 changes: 11 additions & 1 deletion src/spec-lang/tc/typecheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,17 @@ export function tcBinary(expr: SBinaryOperation, ctx: STypingCtx, typeEnv: TypeE

if (["==", "!="].includes(expr.op)) {
// Equality operators allow for the same or implicitly castable types.
unifyTypes(expr.left, lhsT, expr.right, rhsT, expr);
const commonType = unifyTypes(expr.left, lhsT, expr.right, rhsT, expr);

if (commonType instanceof PointerType) {
throw new SWrongType(
`Operator ${
expr.op
} doesn't apply to expression ${expr.left.pp()} of non-value type ${lhsT.pp()}`,
expr.left,
lhsT
);
}
return new BoolType();
}

Expand Down
6 changes: 6 additions & 0 deletions test/unit/tc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,11 @@ describe("TypeChecker Expression Unit Tests", () => {
bool b;
using Lib2 for *;
struct S {
uint x;
}
S sSa;
mapping (uint32 => int64) sM;
function add(uint x, uint y) public returns(uint add) {
Expand Down Expand Up @@ -599,6 +604,7 @@ describe("TypeChecker Expression Unit Tests", () => {
["y<=sV1", ["Foo", "add"]],
["sA>sA", ["Foo", "add"]],
["sA==x", ["Foo", "add"]],
["sSa==sSa", ["Foo", "add"]],
["sA!=1", ["Foo", "add"]],
["x==sV1", ["Foo", "add"]],
["x&sV1", ["Foo", "add"]],
Expand Down

0 comments on commit 6d11dc6

Please sign in to comment.