Skip to content

Commit

Permalink
fixing checkAndInfer for negation (#383)
Browse files Browse the repository at this point in the history
* found and fixed the cause of #337

* adding json file for negation so that it gets tested
  • Loading branch information
ivoysey committed Nov 1, 2021
1 parent 726805a commit fbd200a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions resources/tests/GanacheTests/PrimOpsNeg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gas" : 30000000,
"gasprice" : "0x9184e72a000",
"startingeth" : 5000000,
"numaccts" : 1,
"testexp" : "primopsneg()",
"expected" : "-20"
}
3 changes: 2 additions & 1 deletion src/main/scala/edu/cmu/cs/obsidian/typecheck/Checker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,8 @@ class Checker(globalTable: SymbolTable, verbose: Boolean = false) {
val (typ, con, e1Prime, e2Prime) = assertOperationType(e1, e2, IntType())
(typ, con, Mod(e1Prime, e2Prime).setLoc(e))
case Negate(e: Expression) =>
assertTypeEquality(e, IntType(), context)
val (typ, con, eprime) = assertTypeEquality(e, IntType(), context)
(typ, con, Negate(eprime).setLoc(e))
case Equals(e1: Expression, e2: Expression) =>
val (t1, c1, e1Prime) = inferAndCheckExpr(decl, context, e1, NoOwnershipConsumption())
val (t2, c2, e2Prime) = inferAndCheckExpr(decl, c1, e2, NoOwnershipConsumption())
Expand Down

0 comments on commit fbd200a

Please sign in to comment.