2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 11:18:27 +08:00

compiler.embedding: fix an overly lax hasher.

This commit is contained in:
whitequark 2017-03-02 15:28:24 +00:00 committed by Sebastien Bourdeauducq
parent fd5cdb7d1e
commit 007ae00459

View File

@ -15,7 +15,7 @@ from Levenshtein import ratio as similarity, jaro_winkler
from ..language import core as language_core from ..language import core as language_core
from . import types, builtins, asttyped, prelude from . import types, builtins, asttyped, prelude
from .transforms import ASTTypedRewriter, Inferencer, IntMonomorphizer from .transforms import ASTTypedRewriter, Inferencer, IntMonomorphizer, TypedtreePrinter
from .transforms.asttyped_rewriter import LocalExtractor from .transforms.asttyped_rewriter import LocalExtractor
@ -685,6 +685,8 @@ class TypedtreeHasher(algorithm.Visitor):
def freeze(obj): def freeze(obj):
if isinstance(obj, ast.AST): if isinstance(obj, ast.AST):
return self.visit(obj) return self.visit(obj)
elif isinstance(obj, list):
return hash(tuple(freeze(elem) for elem in obj))
elif isinstance(obj, types.Type): elif isinstance(obj, types.Type):
return hash(obj.find()) return hash(obj.find())
else: else: