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

An obscure JuliaSyntax bug with OhMyREPL.jl #52815

Closed
vlad-circadia opened this issue Jan 8, 2024 · 8 comments
Closed

An obscure JuliaSyntax bug with OhMyREPL.jl #52815

vlad-circadia opened this issue Jan 8, 2024 · 8 comments

Comments

@vlad-circadia
Copy link

The following version was installed via official dmg package:

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M2 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores

The bug:

julia> x = collect(1.2:.5:3.5)
5-element Vector{Float64}:
 1.2
 1.7
 2.2
 2.7
 3.2

julia> round.(Int, x)
ERROR: TypeError: in new, expected Type{JuliaSyntax.Kind}, got Type{Int64}
Stacktrace:
 [1] RefValue
   @ Base ./refvalue.jl:8 [inlined]
 [2] Ref
   @ Base ./refpointer.jl:139 [inlined]
 [3] broadcastable(::Type{Int64})
   @ Base.Broadcast ./broadcast.jl:740
 [4] broadcasted(::typeof(round), ::Type, ::Vector{Float64})
   @ Base.Broadcast ./broadcast.jl:1344
 [5] top-level scope
   @ REPL[8]:1

Interestingly, the bug resists its debugging:

julia> using Debugger

julia> @run round.(Int, x)
5-element Vector{Int64}:
 1
 2
 2
 3
 3
@vlad-circadia
Copy link
Author

The same example on a Linux machine runs without issues:

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 1 × Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, cascadelake)
  Threads: 1 on 1 virtual cores

No bug:

julia> x = collect(1.2:.5:3.5)
5-element Vector{Float64}:
 1.2
 1.7
 2.2
 2.7
 3.2

julia> round.(Int, x)
5-element Vector{Int64}:
 1
 2
 2
 3
 3

@vlad-circadia
Copy link
Author

vlad-circadia commented Jan 8, 2024

On a Mac, the issue is resolved by changing the Int type to Integer.
Observe:

julia> round.(Int, x)
ERROR: TypeError: in new, expected Type{JuliaSyntax.Kind}, got Type{Int64}
Stacktrace:
 [1] RefValue
   @ Base ./refvalue.jl:8 [inlined]
 [2] Ref
   @ Base ./refpointer.jl:139 [inlined]
 [3] broadcastable(::Type{Int64})
   @ Base.Broadcast ./broadcast.jl:740
 [4] broadcasted(::typeof(round), ::Type, ::Vector{Float64})
   @ Base.Broadcast ./broadcast.jl:1344
 [5] top-level scope
   @ REPL[15]:1

julia> round.(Integer, x)
5-element Vector{Int64}:
 1
 2
 2
 3
 3

@mbauman
Copy link
Member

mbauman commented Jan 8, 2024

Similar to #52816, this is likely a package bug from something in your startup. Try with julia --startup-file=no.

@vlad-circadia
Copy link
Author

This is indeed the case. Most likely OhMyREPL. May I ask you to try to reproduce it by running this on a Mac Mx?
I.e., by running using OhMyREPL first in a fresh Julia session.

➜  ~ julia --startup-file=no
              _
  _       _ _(_)_     |  Documentation: https://docs.julialang.org
 (_)     | (_) (_)    |
  _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
 | | | | | | |/ _` |  |
 | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
_/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using OhMyREPL

julia> x = collect(1.2:.5:3.5)
5-element Vector{Float64}:
1.2
1.7
2.2
2.7
3.2

julia> round.(Int,x)
ERROR: TypeError: in new, expected Type{JuliaSyntax.Kind}, got Type{Int64}
Stacktrace:
[1] RefValue
  @ Base ./refvalue.jl:8 [inlined]
[2] Ref
  @ Base ./refpointer.jl:139 [inlined]
[3] broadcastable(::Type{Int64})
  @ Base.Broadcast ./broadcast.jl:740
[4] broadcasted(::typeof(round), ::Type, ::Vector{Float64})
  @ Base.Broadcast ./broadcast.jl:1344
[5] top-level scope
  @ REPL[3]:1

@KristofferC
Copy link
Member

Even though OhMyREPL.jl is required to reproduce this, it still feels to me (unless I miss something obvious) that this could still be a Julia bug. OhMyREPL.jl should not hook into broadcasting for a example.

Ill see if I can repro and understand what is going on.

@vlad-circadia
Copy link
Author

Thanks! Let me know please if I could be of some help.

@mbauman mbauman changed the title An obscure JuliaSyntax bug on Apple Silicon An obscure JuliaSyntax with OhMyREPL.jl Jan 8, 2024
@mbauman mbauman changed the title An obscure JuliaSyntax with OhMyREPL.jl An obscure JuliaSyntax bug with OhMyREPL.jl Jan 8, 2024
@vlad-circadia
Copy link
Author

@vlad-circadia
Copy link
Author

Closing as per KristofferC/OhMyREPL.jl#335 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants