Skip to content

Commit

Permalink
Merge pull request #283 from dritchie/dev
Browse files Browse the repository at this point in the history
Fix how IncrementalMH handles functions defined in external headers.
  • Loading branch information
stuhlmueller committed Jan 7, 2016
2 parents e445f79 + 75d9cc3 commit c092ddd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/inference/incrementalmh.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,17 @@ module.exports = function(env) {
return true;
}

// Checks whether two function are equivalent
// Checks whether two functions are equivalent
var fnEquivCache = {};
function fnsEqual(f1, f2) {
// If the two functions are literally the same closure, then of course
// they are equivalent.
if (f1 === f2) return true;
// Otherwise, they're equivalent if they come from the same source location
// and the values of the variables they close over are the same.
// First, we check if the functions actually have this metadata. External header
// functions do not, so we must return false, to ensure correct behavior.
if (f1.__lexid === undefined || f2.__lexid === undefined) return false;
// We cache this check, because situations often arise where we're checking
// the same pair of functions over and over again.
if (f1.__lexid === f2.__lexid) {
Expand Down

0 comments on commit c092ddd

Please sign in to comment.