# HG changeset patch # User paulb@localhost.localdomain # Date 1165019296 -3600 # Node ID 618ca8ff9c3e5c806c8697a3b3cc1b60976aa686 # Parent a22ab9008cb84815d46905aa90fde2b77b3666d9 Introduced type "merging" for attributes, rather than replacement which is not likely to be correct generally. Introduced empty type lists for unannotated arguments; such arguments may be subsequently annotated when completing recursive analysis. diff -r a22ab9008cb8 -r 618ca8ff9c3e annotate.py --- a/annotate.py Sat Dec 02 00:23:46 2006 +0100 +++ b/annotate.py Sat Dec 02 01:28:16 2006 +0100 @@ -499,7 +499,7 @@ if not attr in non_writes: non_writes.append(attr) continue - attr.type.namespace.store(storeattr.name, expr) + attr.type.namespace.add(storeattr.name, expr) writes[attr.type] = attr.type.namespace.load(storeattr.name) if not writes: print "Unable to store attribute", storeattr.name, "given", self.namespace.types @@ -802,7 +802,10 @@ param, default = params[0] if arg is None: arg = default - items.append((param, arg.types)) + if hasattr(arg, "types"): + items.append((param, arg.types)) + else: + items.append((param, [])) # Annotation has not succeeded. params = params[1:] else: star_args.append(arg) @@ -818,7 +821,10 @@ arg = self.dispatch(default) else: raise AnnotationMessage, "No argument supplied in '%s' for parameter '%s'." % (subprogram, param) - items.append((param, arg.types)) + if hasattr(arg, "types"): + items.append((param, arg.types)) + else: + items.append((param, [])) # Annotation has not succeeded. params = params[1:] dstar_args = kw_args.values() @@ -971,6 +977,12 @@ def set_types(self, types): self.types = types + def add(self, name, types): + if self.names.has_key(name): + combine(self.names[name], types) + else: + self.store(name, types) + def store(self, name, types): self.names[name] = types