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

Formatter breaks array initialization code #745

Closed
gaurav-arya opened this issue Jul 29, 2023 · 1 comment
Closed

Formatter breaks array initialization code #745

gaurav-arya opened this issue Jul 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@gaurav-arya
Copy link

julia> using JuliaFormatter

julia> in_str = "[0.128483; 1.256853; 0.0030203; 0.0027977; 0.0101511; 0.0422942; 0.2391346;
                 0.0008014; 0.0001464; 2.67e-05; 4.8e-6; 9e-7; 0.0619917; 1.2444292; 0.0486676;
                 199.9383546; 137.4267984; 1.5180203; 1.5180203]"
"[0.128483; 1.256853; 0.0030203; 0.0027977; 0.0101511; 0.0422942; 0.2391346;\n          0.0008014; 0.0001464; 2.67e-05; 4.8e-6; 9e-7; 0.0619917; 1.2444292; 0.0486676;\n          199.9383546; 137.4267984; 1.5180203; 1.5180203]"

julia> eval(Meta.parse(in_str))
19-element Vector{Float64}:
   0.128483
   1.256853
   0.0030203
   0.0027977
   0.0101511
   0.0422942
   0.2391346
   0.0008014
   0.0001464
   2.67e-5
   4.8e-6
   9.0e-7
   0.0619917
   1.2444292
   0.0486676
 199.9383546
 137.4267984
   1.5180203
   1.5180203

julia> out_str = format_text(in_str; style=SciMLStyle())
"[0.128483 1.256853 0.0030203 0.0027977 0.0101511 0.0422942 0.2391346\n    0.0008014 0.0001464 2.67e-05 4.8e-6 9e-7 0.0619917 1.2444292 0.0486676\n    199.9383546 137.4267984 1.5180203 1.5180203]"

julia> eval(Meta.parse(out_str))
ERROR: ArgumentError: argument count does not match specified shape (expected 21, got 19)
Stacktrace:
 [1] hvcat(::Tuple{Int64, Int64, Int64}, ::Float64, ::Vararg{Float64})
   @ Base ./abstractarray.jl:2111
 [2] top-level scope
   @ none:1
 [3] eval
   @ ./boot.jl:370 [inlined]
 [4] eval(x::Expr)
   @ Base.MainInclude ./client.jl:480
 [5] top-level scope
   @ REPL[20]:1

Version:

[98e50ef6] JuliaFormatter v1.0.34
@gaurav-arya gaurav-arya changed the title Formatter breaks code Formatter breaks array initialization code Jul 29, 2023
@domluna domluna added the bug Something isn't working label Aug 13, 2023
@Sean1708
Copy link

I'm not sure if it's related or not, but empty n-dimensional literals are also broken:

julia> in_str = "[;;;]"
"[;;;]"

julia> eval(Meta.parse(in_str))
0×0×0 Array{Any, 3}

julia> out_str = format_text(in_str)
"[]"

julia> eval(Meta.parse(out_str))
Any[]

domluna added a commit that referenced this issue Oct 2, 2023
@domluna domluna closed this as completed in ccc6712 Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants