Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Formatter breaks code #28

Closed
rssdev10 opened this issue Dec 2, 2020 · 11 comments
Closed

Formatter breaks code #28

rssdev10 opened this issue Dec 2, 2020 · 11 comments

Comments

@rssdev10
Copy link

rssdev10 commented Dec 2, 2020

JuliaFormatter v0.10.9
julia> versioninfo()
Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, broadwell)
Environment:
  JULIA_EDITOR = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
  JULIA_NUM_THREADS = 

Following code fragment from the attached file:

p = plot([sin, cos], zeros(0),
          leg = false,
          xlims = (0, 2π),
          ylims = (-1, 1))
anim = Animation()
for x = range(0, stop = 2π, length = 20)
    push!(p, x, Float64[sin(x), cos(x)])
    frame(anim)
end
gif(anim, "out/sin_cos_anim.gif", fps = 15)

is completely broken after applying the formatter from VS Code

p = plot([sin, cos], zeros(0), leg = false, xlims = (0, 2π), ylims = (-1, 1))
anim = Animation()
for x in range(0, stop = 2π, length = 20)
    push!(p, x, Float64[sin(x), cos(x)])
    frame(anim)
end
gif(anim, "out/sin_cos_anim.gif", fps = 15)
    push!(p, x, Float64[sin(x), cos(x)])
    frame(anim)
end
gif(anim, "out/sin_cos_anim.gif", fps = 15)

formatter.txt

@casabre
Copy link

casabre commented Mar 4, 2021

I am observing the same within VS Code too. Additionally it takes ages until the formatting has finished in a broken file. Sometimes, the formatting stops with an error message pop-up.

@singularitti
Copy link
Owner

I am aware of this bug, but I am currently occupied and have no time to fix it. Sorry for now!

@casabre
Copy link

casabre commented Mar 11, 2021

I am aware of this bug, but I am currently occupied and have no time to fix it. Sorry for now!

@singularitti I know that it was working. Do you maybe know the version to downgrade for the moment?

@singularitti
Copy link
Owner

I am aware of this bug, but I am currently occupied and have no time to fix it. Sorry for now!

@singularitti I know that it was working. Do you maybe know the version to downgrade for the moment?

0.2.2. I believe the bug was introduced in #24

@FuZhiyu
Copy link

FuZhiyu commented May 12, 2021

I have a similar issue not sure whether it's caused by the same bug, but let me report it here:

function solve_policies!(𝔸, cmat, lmat, smat, umat, V::AbstractArray{D,2}, param; V̇=nothing)
    @unpack 𝔸, cmat, lmat, smat = cache
    w, r = @unpack S
    for iter in CartesianIndices(V)
        nothing
    end
end


function policyfunction(Vbb::D, Vbf, r, w, b, param)
    if validF & (!validB | (Hcf >= Hcb)) 
        c = cf
    elseif validB & (!validF | (Hcb >= Hcf))# & (Hcb >= Hc0)
        c = cb
    else
        c0, l0, s0, u0, Hc0 = solveclSS(r, w, b, param)
    end
    return c, l, s, u
end

will be

function solve_policies!(
    𝔸,
    cmat,
    lmat,
    smat,
    umat,
    V::AbstractArray{D,2},
    param;
    V̇ = nothing,
)
    @unpack 𝔸, cmat, lmat, smat = cache
    w, r = @unpack S
    for iter in CartesianIndices(V)
        nothing
    end
end


function policyfunction(Vbb::D, Vbf, r, w, b, param)
    if validF & (!validB | (Hcf >= Hcb)) 
        c = cf
    elseif validB & (!validF | (Hcb >= Hcf))# & (Hcb >= Hc0)
        c = cb
    else
end


function policyfunction(Vbb::D, Vbf, r, w, b, param)
    if validF & (!validB | (Hcf >= Hcb))
        c = cf
    elseif validB & (!validF | (Hcb >= Hcf))# & (Hcb >= Hc0)
        c = cb
    else

@rben01
Copy link
Contributor

rben01 commented May 31, 2021

I cloned locally and tinkered. Seems like it's sufficient to replace the entire format_stdin() function inside the template string in the return statement ofbuildFormatArgs() with just this :

function format_stdin()
    print(format_text(String(read(stdin)); ${options}))      
end

The current version does some funky reading of stdin with readavailable instead of just reading the whole thing in one go with read.

@rben01
Copy link
Contributor

rben01 commented Jun 1, 2021

Just submitted a PR that I think fixes this.

#40

@singularitti
Copy link
Owner

singularitti commented Jun 2, 2021

Hey guys, @rssdev10, @casabre, @FuZhiyu, can you try v0.5.1 see if it solves your problems?

@rssdev10
Copy link
Author

rssdev10 commented Jun 2, 2021

Thanks, for the code from my primary message it works good.

@FuZhiyu
Copy link

FuZhiyu commented Jun 2, 2021 via email

@jessymilare
Copy link

I was also having this problem and v0.5.1 seems to work fine.

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

No branches or pull requests

6 participants