Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: cannot assign variables whose names match a name exported from Base after any tab autocompletion #30234

Closed
yurivish opened this issue Dec 2, 2018 · 9 comments · Fixed by #30254
Assignees
Labels
REPL Julia's REPL (Read Eval Print Loop)

Comments

@yurivish
Copy link
Contributor

yurivish commented Dec 2, 2018

If you press tab twice to autocomplete a name, the variable names is no longer assignable in global scope.

In a new REPL session:

julia> f<tab><tab>
factorial   fieldoffset  finalizer    findnext     flipsign     for
false       fieldtype    finally      findprev     float        foreach
falses      filemode     findall      first        floatmax     frexp
fd          filesize     findfirst    firstindex   floatmin     fullname
fdio        fill         findlast     fld          floor        function
fetch       fill!        findmax      fld1         flush        functionloc
fieldcount  filter       findmax!     fldmod       fma
fieldname   filter!      findmin      fldmod1      foldl
fieldnames  finalize     findmin!     flip         foldr
julia> names = 10
ERROR: cannot assign variable Base.names from module Main
Stacktrace:
 [1] top-level scope at none:0

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
Environment:
  JULIA_EDITOR = subl

I saw a few related issues (e.g. #23677) but am not sure if they describe the same issue. If they do, feel free to close.

@fredrikekre fredrikekre added the REPL Julia's REPL (Read Eval Print Loop) label Dec 2, 2018
@cstjean
Copy link
Contributor

cstjean commented Dec 3, 2018

Not just names; any Base function, regardless of what was tab-completed.

julia> sin = 1
ERROR: cannot assign variable Base.sin from module Main
Stacktrace:
 [1] top-level scope at none:0

@yurivish yurivish changed the title REPL: cannot assign variable Base.names from module Main REPL: cannot assign variable names (or any other exported from Base) after tab autocompletion Dec 3, 2018
@yurivish yurivish changed the title REPL: cannot assign variable names (or any other exported from Base) after tab autocompletion REPL: cannot assign variables whose names match a name exported from Base after any tab autocompletion Dec 3, 2018
@mauro3
Copy link
Contributor

mauro3 commented Dec 3, 2018

Note that in 0.6 this only threw a warning:

julia> sin = 1
WARNING: imported binding for sin overwritten in module Main
1

@JeffBezanson
Copy link
Member

Maybe fixed by #29962?

@StefanKarpinski
Copy link
Member

No, still happens on master.

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Dec 3, 2018

Weird: I just stopped and restarted Julia and now can't reproduce this. Freshly built Julia. 💢

Here's the entire session, just in case it helps debug this:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0-DEV.790 (2018-12-03)
 _/ |\__'_|_|_|\__'_|  |  Commit a26031e25a (0 days old master)
|__/                   |

julia> ones
ones (generic function with 6 methods)

help?> ones
search: ones leading_ones trailing_ones countlines count_ones to_indices RoundNearest

  ones([T=Float64,] dims...)

  Create an Array, with element type T, of all ones with size specified by dims. See
  also: fill, zeros.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> ones(1,2)
  1×2 Array{Float64,2}:
   1.0  1.0

  julia> ones(ComplexF64, 2, 3)
  2×3 Array{Complex{Float64},2}:
   1.0+0.0im  1.0+0.0im  1.0+0.0im
   1.0+0.0im  1.0+0.0im  1.0+0.0im

julia> zeros
zeros (generic function with 6 methods)

help?> ones
search: ones leading_ones trailing_ones countlines count_ones to_indices RoundNearest

  ones([T=Float64,] dims...)

  Create an Array, with element type T, of all ones with size specified by dims. See
  also: fill, zeros.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> ones(1,2)
  1×2 Array{Float64,2}:
   1.0  1.0

  julia> ones(ComplexF64, 2, 3)
  2×3 Array{Complex{Float64},2}:
   1.0+0.0im  1.0+0.0im  1.0+0.0im
   1.0+0.0im  1.0+0.0im  1.0+0.0im

help?> zeros
search: zeros count_zeros set_zero_subnormals get_zero_subnormals leading_zeros

  zeros([T=Float64,] dims...)

  Create an Array, with element type T, of all zeros with size specified by dims. See
  also fill, ones.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> zeros(1)
  1-element Array{Float64,1}:
   0.0

  julia> zeros(Int8, 2, 3)
  2×3 Array{Int8,2}:
   0  0  0
   0  0  0

julia>
julia> module M
           let x = 1
               f() = x
           end
       end
Main.M

julia> M.f()
ERROR: UndefVarError: f not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at ./sysimg.jl:13
 [2] top-level scope at none:0

julia> module M
           let x = 1
               global f() = x
           end
       end
julia> module M
           let x = 1
               global f() = x
           end
       end
WARNING: replacing module M.
Main.M

julia> M.f()
1

julia> M.x
ERROR: UndefVarError: x not defined

julia> using Dates

julia> 1day
ERROR: MethodError: no method matching *(::Int64, ::typeof(day))
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:502
  *(::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:54
  *(::Union{Int16, Int32, Int64, Int8}, ::BigInt) at gmp.jl:454
  ...
Stacktrace:
 [1] top-level scope at none:0

julia> 1Day
ERROR: MethodError: no method matching *(::Int64, ::Type{Day})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:502
  *(::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:54
  *(::Union{Int16, Int32, Int64, Int8}, ::BigInt) at gmp.jl:454
  ...
Stacktrace:
 [1] top-level scope at none:0

julia> Day(1)
1 day

julia> Date(2014,1,29):Day(1):Date(2014,2,3)
2014-01-29:1 day:2014-02-03

julia> BLAS.gemm!
ERROR: UndefVarError: BLAS not defined

julia> using LinearAlgebra

julia> BLAS
LinearAlgebra.BLAS

julia> BLAS.ge
gemm  gemm!  gemv   gemv!  ger!
julia> BLAS.ge
gemm  gemm!  gemv   gemv!  ger!
julia> BLAS.gemm!
gemm! (generic function with 4 methods)

help?> BLAS.gemm!
  gemm!(tA, tB, alpha, A, B, beta, C)

  Update C as alpha*A*B + beta*C or the other three variants according to tA and tB.
  Return the updated C.

julia>
julia> f

factorial         filesize           findmin!           float
factorize         fill               findnext           floatmax
false             fill!              findprev           floatmin
falses            filter             first              floor
fd                filter!            firstdayofmonth    flush
fdio              finalize           firstdayofquarter  fma
fetch             finalizer          firstdayofweek     foldl
fieldcount        finally            firstdayofyear     foldr
fieldname         findall            firstindex         for
fieldnames        findfirst          fld                foreach
fieldoffset       findlast           fld1               frexp
fieldtype         findmax            fldmod             fullname
fieldtypes        findmax!           fldmod1            function
filemode          findmin            flipsign           functionloc
julia> sin = 1
ERROR: cannot assign variable Base.sin from module Main
Stacktrace:
 [1] top-level scope at none:0

@StefanKarpinski
Copy link
Member

This seems to reproduce it reliably in a fresh session:

julia> using Linear<tab>Algebra

julia> sin = 1
ERROR: cannot assign variable Base.sin from module Main
Stacktrace:
 [1] top-level scope at none:0

@StefanKarpinski
Copy link
Member

In particular, tab completing names seems to be a red herring—it's neither necessary nor sufficient.

@cstjean
Copy link
Contributor

cstjean commented Dec 3, 2018

On a fresh 1.0.2 session, si<tab>n = 1 triggers it every time for me.

@StefanKarpinski
Copy link
Member

That's a different (similar) bug and is already fixed on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants