You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[ ] End-user documentation check. If this PR requires end-user documentation in the Julia VS Code extension docs, please add that at https://github.com/julia-vscode/docs.
5
+
-[ ] Changelog mention. If this PR should be mentioned in the CHANGELOG for the Julia VS Code extension, please open a PR against https://github.com/julia-vscode/julia-vscode/blob/master/CHANGELOG.md with those changes.
if tls.names[name] isa Binding && ((tls.names[name].type == CoreTypes.Function || tls.names[name].type == CoreTypes.DataType) || tls.names[name] isa SymbolServer.FunctionStore || tls.names[name] isa SymbolServer.DataTypeStore)
328
+
329
+
existing_binding = tls.names[name]
330
+
if existing_binding isa Binding && (existing_binding.val isa Binding || existing_binding.val isa SymbolServer.FunctionStore || existing_binding.val isa SymbolServer.DataTypeStore)
331
+
# Should possibly be a while statement
332
+
# If the .val is as above the Binding likely won't have a proper type attached
333
+
# so lets use the .val instead.
334
+
existing_binding = existing_binding.val
335
+
end
336
+
if (existing_binding isa Binding && ((CoreTypes.isfunction(existing_binding.type) || CoreTypes.isdatatype(existing_binding.type))) || existing_binding isa SymbolServer.FunctionStore || existing_binding isa SymbolServer.DataTypeStore)
318
337
# do nothing name of `x` will resolve to the root method
319
338
else
320
339
seterror!(x, CannotDefineFuncAlreadyHasValue)
@@ -333,7 +352,10 @@ function add_binding(x, state, scope=state.scope)
333
352
elseifscopehasbinding(scope, name)
334
353
#TODO: some checks about rebinding of consts
335
354
check_const_decl(name, b, scope)
355
+
336
356
scope.names[name] = b
357
+
elseifis_soft_scope(scope) &&parentof(scope) isa Scope &&isidentifier(b.name) &&scopehasbinding(parentof(scope), valofid(b.name)) &&!enforce_hard_scope(x, scope)
358
+
add_binding(x, state, scope.parent)
337
359
else
338
360
scope.names[name] = b
339
361
end
@@ -343,6 +365,10 @@ function add_binding(x, state, scope=state.scope)
343
365
end
344
366
end
345
367
368
+
functionenforce_hard_scope(x::EXPR, scope)
369
+
scope.expr.head ===:for&&is_in_fexpr(x, x-> x == scope.expr.args[1])
370
+
end
371
+
346
372
name_is_getfield(x) =parentof(x) isa EXPR &&parentof(parentof(x)) isa EXPR && CSTParser.is_getfield_w_quotenode(parentof(parentof(x)))
347
373
348
374
@@ -372,7 +398,7 @@ function mark_globals(x::EXPR, state)
372
398
end
373
399
374
400
functionname_extends_imported_method(b::Binding)
375
-
if b.type== CoreTypes.Function&& CSTParser.hasparent(b.name) && CSTParser.is_getfield(parentof(b.name))
iscoretype(x::SymbolServer.VarRef, name) = x isa SymbolServer.DataTypeStore && x.name.name == name && x.name isa SymbolServer.VarRef && x.name.parent.name ==:Core
23
+
iscoretype(x::SymbolServer.DataTypeStore, name) = x isa SymbolServer.DataTypeStore && x.name.name.name == name && x.name.name isa SymbolServer.VarRef && x.name.name.parent.name ==:Core
24
+
isdatatype(x) =iscoretype(x, :DataType)
25
+
isfunction(x) =iscoretype(x, :Function)
26
+
ismodule(x) =iscoretype(x, :Module)
27
+
isstring(x) =iscoretype(x, :String)
28
+
ischar(x) =iscoretype(x, :Char)
29
+
issymbol(x) =iscoretype(x, :Symbol)
30
+
@staticif Core.Int == Core.Int64
31
+
isint(x) =iscoretype(x, :Int64)
32
+
else
33
+
isint(x) =iscoretype(x, :Int32)
34
+
end
35
+
isfloat(x) =iscoretype(x, :Float64)
36
+
isvector(x) =iscoretype(x, :Vector)
37
+
isarray(x) =iscoretype(x, :Array)
38
+
isva(x::SymbolServer.FakeUnionAll) =isva(x.body)
39
+
@staticif Core.Vararg isa Core.Type
40
+
functionisva(x)
41
+
return (x isa SymbolServer.FakeTypeName && x.name.name ==:Vararg&&
42
+
x.name.parent isa SymbolServer.VarRef && x.name.parent.name ==:Core)
0 commit comments