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

[BUG] Format Code creates wrong function name #331

Closed
feanor12 opened this issue Jul 23, 2019 · 3 comments
Closed

[BUG] Format Code creates wrong function name #331

feanor12 opened this issue Jul 23, 2019 · 3 comments
Labels

Comments

@feanor12
Copy link

feanor12 commented Jul 23, 2019

Formatting changes the function name and removes T.

Details

  • Atom version: 1.38.2
  • Julia Version 1.1.1 Commit 55e36cc308 (2019-05-16 04:10 UTC)
  • OS: Win 10

Packages:

  • Atom v0.8.8
  • Juno v0.7.0
  • julia-client 0.8.10
  • ink 0.10.11
  • language-julia: 0.19.1

Steps to reproduce

  1. open a file with:
struct PolarComplex{T<:Real} <: Number
    R::T
    θ::T
    PolarComplex(R::T, θ::T) where T <: Real =
        new{T}(R, mod(θ,2π))
end
  1. click format code on the toolbar
  2. get:
struct PolarComplex{T <: Real} <: Number
    R::T
    θ::T
    PolarComplex(R::T, θ::T) where T <: Real =
        new{}(R, od(θ, 2π))
end
@feanor12 feanor12 added the bug label Jul 23, 2019
@aviatesk
Copy link
Member

aviatesk commented Jul 23, 2019

Umm I can't reproduce this.

And it doesn't even seems to be from DocumentFormat.jl, which we use internally.

If we run

using DocumentFormat
"""
struct PolarComplex{T <: Real} <: Number
    R::T
    θ::T
    PolarComplex(R::T, θ::T) where T <: Real =
        new{T}(R, mod(θ, 2π))
end
""" |> format |> println

We get this

struct PolarComplex{T <: Real} <: Number
    R::T
    θ::T
    PolarComplex(R::T, θ::T) where T <: Real =
        new{T}(R, mod(θ, 2π))
end

@feanor12
Copy link
Author

feanor12 commented Jul 23, 2019

If I take the file format.txt, rename it to format.jl, open it in Juno and select Run All I get :

struct PolarComplex{T <: Real} <: Number
    R::T
    θ::T
    PolarComplex(R::T, θ::T) where T <: Real =
        new{T(R, md2pi(θ))
end

When I select the content and paste it into the REPL I get:

struct PolarComplex{T <: Real} <: Number

    R::T

    θ::T

    PolarComplex(R::T, θ::T) where T <: Real =

                  new{T}(R, mod2pi(θ))

end

DocumentFormat has version 0.4.0.

@pfitzseb
Copy link
Member

pfitzseb commented Aug 7, 2019

Our new code formatter makes sure that the original and reformatted code parse the same, so things like this shouldn't happen anymore.

@pfitzseb pfitzseb closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants