Skip to content

Commit

Permalink
fix chained attribute calls exponential time (#84)
Browse files Browse the repository at this point in the history
* fix chained attribute calls exponential time

* fix and add test data
  • Loading branch information
yinwang0 authored Feb 1, 2017
1 parent 261a5fc commit dc6d8f1
Show file tree
Hide file tree
Showing 3 changed files with 546 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/org/yinwang/pysonar/visitor/TypeInferencer.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,24 @@ public Type visit(Bytes node, State s) {
@NotNull
@Override
public Type visit(Call node, State s) {
Type fun = visit(node.func, s);
Type fun;
Type selfType = null;

if (node.func instanceof Attribute)
{
Node target = ((Attribute) node.func).target;
Name attr = ((Attribute) node.func).attr;
selfType = visit(target, s);
Set<Binding> b = selfType.table.lookupAttr(attr.id);
if (b != null) {
Analyzer.self.putRef(attr, b);
fun = State.makeUnion(b);
} else {
Analyzer.self.putProblem(attr, "Attribute is not found in type: " + attr.id);
fun = Types.UNKNOWN;
}
} else {
fun = visit(node.func, s);
}

// Infer positional argument types
Expand Down
Loading

0 comments on commit dc6d8f1

Please sign in to comment.