Skip to content

Commit

Permalink
Fixed end-of-transaction type checks that occur on return(e) so they …
Browse files Browse the repository at this point in the history
…use the new context (after consuming e), not the old one.

Avoided a redundant end-of-transaction type check that can occur in transactions that return.
  • Loading branch information
mcoblenz committed Jan 23, 2020
1 parent 829e7b1 commit 2531079
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/scala/edu/cmu/cs/obsidian/typecheck/Checker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1598,11 +1598,11 @@ class Checker(globalTable: SymbolTable, verbose: Boolean = false) {
}

checkForUnusedOwnershipErrors(s, contextPrime, thisSetToExclude ++ argsSetToExclude)
checkFieldTypeConsistencyAfterTransaction(context, decl, s)
checkFieldTypeConsistencyAfterTransaction(contextPrime, decl, s)


if (retTypeOpt.isDefined && !retTypeOpt.get.isBottom) {
checkIsSubtype(context.contractTable, s, typ, retTypeOpt.get)
checkIsSubtype(contextPrime.contractTable, s, typ, retTypeOpt.get)
}
(contextPrime, ReturnExpr(ePrime))

Expand Down Expand Up @@ -2443,7 +2443,10 @@ class Checker(globalTable: SymbolTable, verbose: Boolean = false) {
}

// Check to make sure all the field types are consistent with their declarations.
checkFieldTypeConsistencyAfterTransaction(outputContext, tx, tx.bodyEnd)
// But don't bother checking if the body is guaranteed to return, in which case this check was already done.
if (!hasReturnStatementDontLog(tx.body)) {
checkFieldTypeConsistencyAfterTransaction(outputContext, tx, tx.bodyEnd)
}

// todo: check that every declared variable is initialized before use
tx.copy(body = newStatements)
Expand Down

0 comments on commit 2531079

Please sign in to comment.