Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8bca56b
Fix #668 (partial)
Mar 1, 2019
a731c2a
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 1, 2019
069910b
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
7ffc9db
Tests
Mar 5, 2019
6303c45
Revert "Tests"
Mar 5, 2019
945451c
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
034e437
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
f997d68
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 6, 2019
0e4ff95
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 11, 2019
878c8c5
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 13, 2019
35e1033
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 13, 2019
1073711
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 14, 2019
86028da
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 14, 2019
4d4bca7
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 18, 2019
ac04f76
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 18, 2019
bab03da
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 20, 2019
85ec685
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 27, 2019
be7466d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
01781c0
Exp
Mar 27, 2019
f544f8a
Limit concurrency
Mar 28, 2019
01bd719
Concurrency limit
Mar 28, 2019
2f8e564
Drop cache after analysis
Mar 28, 2019
9a933bd
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
4ad56bb
Fix regression
Mar 28, 2019
c280c55
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 3, 2019
529157c
Fix extra eval in list concatenation
Apr 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@ private IMember GetValueFromBinaryOp(Expression expr) {
case PythonOperator.NotIn:
// Assume all of these return True/False
return Interpreter.GetBuiltinType(BuiltinTypeId.Bool);
}

var left = GetValueFromExpression(binop.Left) ?? UnknownType;
var right = GetValueFromExpression(binop.Right) ?? UnknownType;

switch (binop.Operator) {
case PythonOperator.Divide:
case PythonOperator.TrueDivide:
if (Interpreter.LanguageVersion.Is3x()) {
Expand All @@ -110,30 +105,33 @@ private IMember GetValueFromBinaryOp(Expression expr) {
break;
}

if (right.GetPythonType()?.TypeId == BuiltinTypeId.Float) {
var left = GetValueFromExpression(binop.Left) ?? UnknownType;
var right = GetValueFromExpression(binop.Right) ?? UnknownType;


var rightType = right.GetPythonType();
if (rightType?.TypeId == BuiltinTypeId.Float) {
return right;
}

if (left.GetPythonType()?.TypeId == BuiltinTypeId.Float) {
var leftType = left.GetPythonType();
if (leftType?.TypeId == BuiltinTypeId.Float) {
return left;
}

if (right.GetPythonType()?.TypeId == BuiltinTypeId.Long) {
if (rightType?.TypeId == BuiltinTypeId.Long) {
return right;
}

if (left.GetPythonType()?.TypeId == BuiltinTypeId.Long) {
if (leftType?.TypeId == BuiltinTypeId.Long) {
return left;
}

if (binop.Operator == PythonOperator.Add
&& left.GetPythonType()?.TypeId == BuiltinTypeId.List
&& right.GetPythonType()?.TypeId == BuiltinTypeId.List) {

var leftVar = GetValueFromExpression(binop.Left) as IPythonCollection;
var rightVar = GetValueFromExpression(binop.Right) as IPythonCollection;
if (binop.Operator == PythonOperator.Add
&& leftType?.TypeId == BuiltinTypeId.List && rightType?.TypeId == BuiltinTypeId.List
&& left is IPythonCollection lc && right is IPythonCollection rc) {

return PythonCollectionType.CreateConcatenatedList(Module.Interpreter, GetLoc(expr), leftVar?.Contents, rightVar?.Contents);
return PythonCollectionType.CreateConcatenatedList(Module.Interpreter, GetLoc(expr), lc.Contents, rc.Contents);
}

return left.IsUnknown() ? right : left;
Expand Down
6 changes: 6 additions & 0 deletions src/Analysis/Ast/Test/AssignmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,11 @@ public async Task IncompleteTuple() {
analysis.Should().HaveVariable("a").OfType(BuiltinTypeId.Int)
.And.HaveVariable("b").OfType(BuiltinTypeId.Int);
}

[TestMethod, Priority(0)]
public async Task Uts46dataModule() {
const string code = @"from idna.uts46data import *";
await GetAnalysisAsync(code);
}
}
}