Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Find all references and rename #819

Merged
merged 105 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 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
d0ed529
Partial
Mar 21, 2019
d025fbb
Part 2
Mar 21, 2019
3bb184c
Part 3
Mar 21, 2019
d366b83
Part 4
Mar 21, 2019
9b8a695
Part 4
Mar 21, 2019
af7ee97
Part 5
Mar 21, 2019
6ce3979
Analysis tests
Mar 22, 2019
9c94717
Tests
Mar 22, 2019
a0b6146
Tests
Mar 22, 2019
deaec46
Basic test
Mar 22, 2019
9c6f54a
Tests
Mar 23, 2019
32fa216
Tests
Mar 23, 2019
b3488d1
Tests
Mar 23, 2019
30b9105
Tests
Mar 23, 2019
1b5fb4b
Tests
Mar 24, 2019
2a318ce
Linked variables
Mar 24, 2019
9209e6a
Tests
Mar 24, 2019
2c8b795
Tests
Mar 24, 2019
8c5d772
Tests
Mar 24, 2019
fecb99b
Merge master
Mar 24, 2019
862c308
Merge issues
Mar 24, 2019
8692c50
Fix merge issue
Mar 25, 2019
e3eca94
Basic single file
Mar 25, 2019
025c0c6
Handle closed files
Mar 25, 2019
806c0bb
Closed files
Mar 25, 2019
cc99021
Tests
Mar 26, 2019
0de232c
Tests
Mar 26, 2019
2c28df5
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 26, 2019
c9f2016
Fix 454
Mar 26, 2019
583a22e
Remove references on analysis change
Mar 26, 2019
dbf716e
Rename
Mar 26, 2019
4b415a1
Rename non-user code
Mar 26, 2019
44f39d0
Linter
Mar 26, 2019
1f93f40
Ref fix
Mar 26, 2019
84ae8ce
Member expressions
Mar 27, 2019
e516986
Linter improvements
Mar 27, 2019
8454629
Tests
Mar 27, 2019
6320ecf
Definitions only for LHS
Mar 27, 2019
e909641
Add test
Mar 27, 2019
f1ae706
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 27, 2019
29053c4
Merge master
Mar 28, 2019
8f3b475
Add null checks and tests
Mar 28, 2019
a34a9f8
Null checks
Mar 28, 2019
90d72d3
Fix variable leak in expressions with comprehensions
Mar 28, 2019
20af82a
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
6f9008d
Temp
Mar 28, 2019
a3a90f9
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
cc740ab
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 29, 2019
8a58d55
Fix scope lookup + test
Mar 29, 2019
5dfc290
Handle virtual space
Mar 29, 2019
6352288
Better handle nested sequence expression assignments
Mar 29, 2019
3d3d085
More extensive handling of RHS sequences
Mar 29, 2019
05c6a77
PR feedback
Mar 30, 2019
f574f5f
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 30, 2019
03d773f
Merge branch 'refs' into re
Apr 1, 2019
fb7b571
Enable test
Apr 1, 2019
0d9c9b7
Test stability
Apr 1, 2019
ff678eb
Don't collect references to library modules
Apr 1, 2019
93c301c
Handle virtual envs
Apr 2, 2019
706ae04
PR feedback
Apr 2, 2019
65d77ce
Merge master
Apr 2, 2019
4c23878
null check
Apr 2, 2019
9d81a52
Remove references in all modules
Apr 3, 2019
c2b8df0
Add test
Apr 3, 2019
e93eb3d
Perf improvement
Apr 3, 2019
5e7d6c9
Null check in tests
Apr 3, 2019
a8315f5
Merge master
Apr 3, 2019
ca90131
Merge master
Apr 3, 2019
f49bcbf
Store span rather than node
Apr 4, 2019
30ae1f6
Fix AST associations with locations
Apr 4, 2019
d069c9d
Handle null nodes
Apr 4, 2019
002147c
Temp
Apr 4, 2019
99d0dd3
Add AST to nodes
Apr 5, 2019
6d9b95a
Variable refs
Apr 5, 2019
9663ae4
Null ref
Apr 5, 2019
03a0421
Merge master
Apr 5, 2019
21d64c0
Merge issues
Apr 5, 2019
e7998a6
Handle import *
Apr 5, 2019
bbc9fe9
Undo debug
Apr 5, 2019
77adaa1
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 5, 2019
809632f
Merge issues
Apr 5, 2019
ef9072e
Better handle variable
Apr 5, 2019
d028b15
Null check
Apr 5, 2019
17882a4
Better handle nested variables without location
Apr 6, 2019
c28900d
Fix rename test
Apr 6, 2019
7f54bd7
Usings
Apr 7, 2019
f4738a6
Merge master
Apr 8, 2019
d007067
Fix merge conflict
Apr 8, 2019
468f0d9
Merge master
Apr 8, 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
3 changes: 0 additions & 3 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ in [Filing an issue](#filing-an-issue).

There are a few known issues in the current version of the language server:

- Find references and rename functionality is not yet implemented.
- See [#699](https://github.com/Microsoft/python-language-server/issues/699),
[#577](https://github.com/Microsoft/python-language-server/issues/577).
- Not all `__all__` statements can be handled.
- Some modules may have an incorrect list of exported names.
See [#620](https://github.com/Microsoft/python-language-server/issues/620),
Expand Down
7 changes: 7 additions & 0 deletions src/Analysis/Ast/Impl/Analyzer/AnalysisWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public override bool Walk(ExpressionStatement node) {
case Comprehension comp:
Eval.ProcessComprehension(comp);
return false;
case CallExpression callex when callex.Target is NameExpression nex && !string.IsNullOrEmpty(nex.Name):
Eval.LookupNameInScopes(nex.Name)?.AddReference(Eval.GetLocationOfName(nex));
return false;
case CallExpression callex when callex.Target is MemberExpression mex && !string.IsNullOrEmpty(mex.Name):
var t = Eval.GetValueFromExpression(mex.Target)?.GetPythonType();
t?.GetMember(mex.Name).AddReference(Eval.GetLocationOfName(mex));
return false;
default:
return base.Walk(node);
}
Expand Down
7 changes: 5 additions & 2 deletions src/Analysis/Ast/Impl/Analyzer/Definitions/IAnalyzable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
// See the Apache Version 2.0 License for specific language governing
// permissions and limitations under the License.

using System;

namespace Microsoft.Python.Analysis.Analyzer {
/// <summary>
/// Represents document that can be analyzed asynchronously.
/// </summary>
internal interface IAnalyzable {
/// <summary>
/// Notifies document that analysis is about to begin.
/// </summary>
void NotifyAnalysisBegins();

/// <summary>
/// Notifies document that its analysis is now complete.
/// </summary>
Expand Down
26 changes: 23 additions & 3 deletions src/Analysis/Ast/Impl/Analyzer/Definitions/IExpressionEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using Microsoft.Python.Analysis.Analyzer.Evaluation;
using Microsoft.Python.Analysis.Diagnostics;
using Microsoft.Python.Analysis.Types;
using Microsoft.Python.Analysis.Values;
Expand Down Expand Up @@ -56,18 +55,39 @@ public interface IExpressionEvaluator {
/// <summary>
/// Evaluates expression in the currently open scope.
/// </summary>
IMember GetValueFromExpression(Expression expr);
IMember GetValueFromExpression(Expression expr, LookupOptions options = LookupOptions.Normal);

IMember LookupNameInScopes(string name, out IScope scope, LookupOptions options = LookupOptions.Normal);
IMember LookupNameInScopes(string name, out IScope scope, out IVariable v, LookupOptions options = LookupOptions.Normal);

IPythonType GetTypeFromString(string typeString);

/// <summary>
/// Module AST.
/// </summary>
PythonAst Ast { get; }

/// <summary>
/// Associated module.
/// </summary>
IPythonModule Module { get; }

/// <summary>
/// Interpreter used in the module analysis.
/// </summary>
IPythonInterpreter Interpreter { get; }

/// <summary>
/// Application service container.
/// </summary>
IServiceContainer Services { get; }

void ReportDiagnostics(Uri documentUri, DiagnosticsEntry entry);

IEnumerable<DiagnosticsEntry> Diagnostics { get; }

/// <summary>
/// Represents built-in 'unknown' type. <see cref="BuiltinTypeId.Unknown"/>.
/// </summary>
IPythonType UnknownType { get; }
}
}
5 changes: 5 additions & 0 deletions src/Analysis/Ast/Impl/Analyzer/Definitions/IPythonAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ public interface IPythonAnalyzer {
/// Removes all the modules from the analysis, except Typeshed and builtin
/// </summary>
void ResetAnalyzer();

/// <summary>
/// Returns list of currently loaded modules.
/// </summary>
IReadOnlyList<IPythonModule> LoadedModules { get; }
}
}
8 changes: 4 additions & 4 deletions src/Analysis/Ast/Impl/Analyzer/Definitions/LookupOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace Microsoft.Python.Analysis.Analyzer {
[Flags]
public enum LookupOptions {
None = 0,
Local,
Nonlocal,
Global,
Builtins,
Local = 1,
Nonlocal = 2,
Global = 4,
Builtins = 8,
Normal = Local | Nonlocal | Global | Builtins
}
}
2 changes: 1 addition & 1 deletion src/Analysis/Ast/Impl/Analyzer/DocumentAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public EmptyAnalysis(IServiceContainer services, IDocument document) {
Document = document ?? throw new ArgumentNullException(nameof(document));
GlobalScope = new EmptyGlobalScope(document);

_emptyAst = _emptyAst ?? (_emptyAst = Parser.CreateParser(new StringReader(string.Empty), PythonLanguageVersion.None).ParseFile());
_emptyAst = _emptyAst ?? (_emptyAst = Parser.CreateParser(new StringReader(string.Empty), PythonLanguageVersion.None).ParseFile(document.Uri));
ExpressionEvaluator = new ExpressionEval(services, document, Ast);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public IMember GetValueFromCallable(CallExpression expr) {
}

var target = GetValueFromExpression(expr.Target);
target?.AddReference(GetLocationOfName(expr.Target));

var result = GetValueFromGeneric(target, expr);
if (result != null) {
return result;
Expand All @@ -58,7 +60,7 @@ public IMember GetValueFromCallable(CallExpression expr) {
case IPythonType t:
// Target is type (info), the call creates instance.
// For example, 'x = C; y = x()' or 'x = C()' where C is class
value = new PythonInstance(t, GetLoc(expr));
value = new PythonInstance(t);
break;
}

Expand All @@ -74,9 +76,9 @@ public IMember GetValueFromLambda(LambdaExpression expr) {
return null;
}

var loc = GetLoc(expr);
var ft = new PythonFunctionType(expr.Function, Module, null, loc);
var overload = new PythonFunctionOverload(expr.Function, ft, Module, GetLoc(expr));
var location = GetLocationOfName(expr.Function);
var ft = new PythonFunctionType(expr.Function, null, location);
var overload = new PythonFunctionOverload(expr.Function, ft, location);
ft.AddOverload(overload);
return ft;
}
Expand All @@ -93,7 +95,7 @@ public IMember GetValueFromClassCtor(IPythonClassType cls, CallExpression expr)
}
args = a.Evaluate();
}
return cls.CreateInstance(cls.Name, GetLoc(expr), args);
return cls.CreateInstance(cls.Name, args);
}

public IMember GetValueFromBound(IPythonBoundType t, CallExpression expr) {
Expand Down Expand Up @@ -190,7 +192,7 @@ public IMember GetValueFromFunctionType(IPythonFunctionType fn, IPythonInstance

// Try and evaluate with specific arguments. Note that it does not
// make sense to evaluate stubs since they already should be annotated.
if (fn.DeclaringModule is IDocument doc && fd?.IsInAst(doc.GetAnyAst()) == true) {
if (fn.DeclaringModule is IDocument doc && fd?.Ast == doc.GetAnyAst()) {
// Stubs are coming from another module.
return TryEvaluateWithArguments(fn.DeclaringModule, fd, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IMember GetValueFromList(ListExpression expression) {
var value = GetValueFromExpression(item) ?? UnknownType;
contents.Add(value);
}
return PythonCollectionType.CreateList(Module.Interpreter, GetLoc(expression), contents, exact: true);
return PythonCollectionType.CreateList(Module.Interpreter, contents);
}

public IMember GetValueFromDictionary(DictionaryExpression expression) {
Expand All @@ -70,7 +70,7 @@ public IMember GetValueFromDictionary(DictionaryExpression expression) {
var value = GetValueFromExpression(item.SliceStop) ?? UnknownType;
contents[key] = value;
}
return new PythonDictionary(Interpreter, GetLoc(expression), contents, exact: true);
return new PythonDictionary(Interpreter, contents);
}

private IMember GetValueFromTuple(TupleExpression expression) {
Expand All @@ -79,7 +79,7 @@ private IMember GetValueFromTuple(TupleExpression expression) {
var value = GetValueFromExpression(item) ?? UnknownType;
contents.Add(value);
}
return PythonCollectionType.CreateTuple(Module.Interpreter, GetLoc(expression), contents, exact: true);
return PythonCollectionType.CreateTuple(Module.Interpreter, contents);
}

public IMember GetValueFromSet(SetExpression expression) {
Expand All @@ -88,7 +88,7 @@ public IMember GetValueFromSet(SetExpression expression) {
var value = GetValueFromExpression(item) ?? UnknownType;
contents.Add(value);
}
return PythonCollectionType.CreateSet(Interpreter, GetLoc(expression), contents, exact: true);
return PythonCollectionType.CreateSet(Interpreter, contents);
}

public IMember GetValueFromGenerator(GeneratorExpression expression) {
Expand All @@ -108,14 +108,14 @@ public IMember GetValueFromComprehension(Comprehension node) {
switch (node) {
case ListComprehension lc:
var v1 = GetValueFromExpression(lc.Item) ?? UnknownType;
return PythonCollectionType.CreateList(Interpreter, GetLoc(lc), new[] { v1 });
return PythonCollectionType.CreateList(Interpreter, new[] { v1 });
case SetComprehension sc:
var v2 = GetValueFromExpression(sc.Item) ?? UnknownType;
return PythonCollectionType.CreateSet(Interpreter, GetLoc(sc), new[] { v2 });
return PythonCollectionType.CreateSet(Interpreter, new[] { v2 });
case DictionaryComprehension dc:
var k = GetValueFromExpression(dc.Key) ?? UnknownType;
var v = GetValueFromExpression(dc.Value) ?? UnknownType;
return new PythonDictionary(new PythonDictionaryType(Interpreter), GetLoc(dc), new Dictionary<IMember, IMember> { { k, v } });
return new PythonDictionary(new PythonDictionaryType(Interpreter), new Dictionary<IMember, IMember> { { k, v } });
}

return UnknownType;
Expand All @@ -138,20 +138,20 @@ internal void ProcessComprehension(Comprehension node) {
if (value != null) {
switch (cfor.Left) {
case NameExpression nex when value is IPythonCollection coll:
DeclareVariable(nex.Name, coll.GetIterator().Next, VariableSource.Declaration, GetLoc(nex));
DeclareVariable(nex.Name, coll.GetIterator().Next, VariableSource.Declaration, nex);
break;
case NameExpression nex:
DeclareVariable(nex.Name, UnknownType, VariableSource.Declaration, GetLoc(nex));
DeclareVariable(nex.Name, UnknownType, VariableSource.Declaration, nex);
break;
case TupleExpression tex when value is IPythonDictionary dict && tex.Items.Count > 0:
if (tex.Items[0] is NameExpression nx0 && !string.IsNullOrEmpty(nx0.Name)) {
DeclareVariable(nx0.Name, dict.Keys.FirstOrDefault() ?? UnknownType, VariableSource.Declaration, GetLoc(nx0));
DeclareVariable(nx0.Name, dict.Keys.FirstOrDefault() ?? UnknownType, VariableSource.Declaration, nx0);
}
if (tex.Items.Count > 1 && tex.Items[1] is NameExpression nx1 && !string.IsNullOrEmpty(nx1.Name)) {
DeclareVariable(nx1.Name, dict.Values.FirstOrDefault() ?? UnknownType, VariableSource.Declaration, GetLoc(nx1));
DeclareVariable(nx1.Name, dict.Values.FirstOrDefault() ?? UnknownType, VariableSource.Declaration, nx1);
}
foreach (var item in tex.Items.Skip(2).OfType<NameExpression>().Where(x => !string.IsNullOrEmpty(x.Name))) {
DeclareVariable(item.Name, UnknownType, VariableSource.Declaration, GetLoc(item));
DeclareVariable(item.Name, UnknownType, VariableSource.Declaration, item);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@
namespace Microsoft.Python.Analysis.Analyzer.Evaluation {
internal sealed partial class ExpressionEval {
public IPythonInstance GetConstantFromLiteral(Expression expr, LookupOptions options) {
var location = GetLoc(expr);
if (expr is ConstantExpression ce) {
switch (ce.Value) {
case string s:
return new PythonUnicodeString(s, Interpreter, location);
return new PythonUnicodeString(s, Interpreter);
case AsciiString b:
return new PythonAsciiString(b, Interpreter, location);
return new PythonAsciiString(b, Interpreter);
case int integer:
return new PythonConstant(integer, Interpreter.GetBuiltinType(BuiltinTypeId.Int), location);
return new PythonConstant(integer, Interpreter.GetBuiltinType(BuiltinTypeId.Int));
}
}

var t = SuppressBuiltinLookup ? UnknownType : (GetTypeFromLiteral(expr) ?? UnknownType);
return new PythonInstance(t, location);
return new PythonInstance(t);
}

public IPythonType GetTypeFromLiteral(Expression expr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private IMember CreateSpecificTypeFromIndex(IGenericType gt, IReadOnlyList<IMemb
if (gt.Name.EqualsOrdinal("Generic")) {
// Generic[T1, T2, ...] expression. Create generic base for the class.
if (genericTypeArgs.Length > 0) {
return new GenericClassParameter(genericTypeArgs, Module, GetLoc(expr));
return new GenericClassParameter(genericTypeArgs, Module);
} else {
// TODO: report too few type arguments for Generic[].
return UnknownType;
Expand All @@ -88,7 +88,7 @@ private IMember CreateSpecificTypeFromIndex(IGenericType gt, IReadOnlyList<IMemb

// For other types just use supplied arguments
if (indices.Count > 0) {
return gt.CreateSpecificType(new ArgumentSet(indices), Module, GetLoc(expr));
return gt.CreateSpecificType(new ArgumentSet(indices));
}
// TODO: report too few type arguments for the generic expression.
return UnknownType;
Expand Down Expand Up @@ -127,7 +127,6 @@ private IReadOnlyList<IMember> EvaluateCallArgs(CallExpression expr) {
private IMember CreateClassInstance(PythonClassType cls, IReadOnlyList<IMember> constructorArguments, CallExpression callExpr) {
// Look at the constructor arguments and create argument set
// based on the __init__ definition.
var location = GetLoc(callExpr);
var initFunc = cls.GetMember(@"__init__") as IPythonFunctionType;
var initOverload = initFunc?.DeclaringType == cls ? initFunc.Overloads.FirstOrDefault() : null;

Expand All @@ -136,8 +135,8 @@ private IMember CreateClassInstance(PythonClassType cls, IReadOnlyList<IMember>
: new ArgumentSet(constructorArguments);

argSet.Evaluate();
var specificType = cls.CreateSpecificType(argSet, Module, location);
return new PythonInstance(specificType, location);
var specificType = cls.CreateSpecificType(argSet);
return new PythonInstance(specificType);
}

private ScopeStatement GetScope(IMember m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Microsoft.Python.Analysis.Analyzer.Evaluation {
/// </summary>
internal sealed partial class ExpressionEval {
public IPythonType GetTypeFromPepHint(Node node) {
var location = GetLoc(node);
var location = GetLocationInfo(node);
var content = (Module as IDocument)?.Content;
if (string.IsNullOrEmpty(content) || !location.EndLine.HasValue) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// See the Apache Version 2.0 License for specific language governing
// permissions and limitations under the License.

using System;
using System.Collections.Generic;
using Microsoft.Python.Analysis.Modules;
using Microsoft.Python.Analysis.Types;
using Microsoft.Python.Analysis.Types.Collections;
Expand Down Expand Up @@ -54,14 +52,16 @@ private IMember GetValueFromUnaryOp(UnaryExpression expr, string op) {
}
}
return instance is IPythonConstant c && instance.TryGetConstant<int>(out var value)
? new PythonConstant(-value, c.Type, GetLoc(expr))
? new PythonConstant(-value, c.Type)
: instance;
}
return UnknownType;
}

private IMember GetValueFromBinaryOp(Expression expr) {
if (expr is AndExpression) {
if (expr is AndExpression a) {
GetValueFromExpression(a.Left);
GetValueFromExpression(a.Right);
return Interpreter.GetBuiltinType(BuiltinTypeId.Bool);
}

Expand Down Expand Up @@ -108,7 +108,6 @@ private IMember GetValueFromBinaryOp(Expression expr) {
var left = GetValueFromExpression(binop.Left) ?? UnknownType;
var right = GetValueFromExpression(binop.Right) ?? UnknownType;


var rightType = right.GetPythonType();
if (rightType?.TypeId == BuiltinTypeId.Float) {
return right;
Expand All @@ -131,7 +130,7 @@ private IMember GetValueFromBinaryOp(Expression expr) {
&& leftType?.TypeId == BuiltinTypeId.List && rightType?.TypeId == BuiltinTypeId.List
&& left is IPythonCollection lc && right is IPythonCollection rc) {

return PythonCollectionType.CreateConcatenatedList(Module.Interpreter, GetLoc(expr), lc, rc);
return PythonCollectionType.CreateConcatenatedList(Module.Interpreter, lc, rc);
}

return left.IsUnknown() ? right : left;
Expand Down
Loading