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

error formatting stdlib of Julia #644

Closed
Moelf opened this issue Oct 7, 2022 · 8 comments · Fixed by #646
Closed

error formatting stdlib of Julia #644

Moelf opened this issue Oct 7, 2022 · 8 comments · Fixed by #646
Labels
bug Something isn't working

Comments

@Moelf
Copy link

Moelf commented Oct 7, 2022

julia> format("./stdlib/", MinimalStyle(); normalize_line_endings = "unix", align_assignment=true)
[ Info: Error in formatting file stdlib/InteractiveUtils/test/runtests.jl
ERROR: ArgumentError: invalid index: nothing of type Nothing
@domluna
Copy link
Owner

domluna commented Oct 7, 2022

@Moelf can you post the commit of the Julia repo so I can debug

also verbose=true will help a bit

@domluna domluna added the bug Something isn't working label Oct 7, 2022
@Moelf
Copy link
Author

Moelf commented Oct 7, 2022

the commit is JuliaLang/julia@f927d25
there's no additional msg from verbose=true

[ Info: Error in formatting file stdlib/InteractiveUtils/test/runtests.jl
Formatting stdlib/InteractiveUtils/test/runtests.jl
ERROR: ArgumentError: invalid index: nothing of type Nothing
Stacktrace:
  [1] to_index(i::Nothing)
    @ Base ./indices.jl:300
  [2] to_index(A::Vector{JuliaFormatter.FST}, i::Nothing)
    @ Base ./indices.jl:277
  [3] to_indices
    @ ./indices.jl:333 [inlined]
  [4] to_indices
    @ ./indices.jl:325 [inlined]
  [5] getindex
    @ ./abstractarray.jl:1241 [inlined]
  [6] getindex
    @ ~/.julia/packages/JuliaFormatter/xKNsr/src/fst.jl:182 [inlined]
  [7] align_binaryopcalls!(fst::JuliaFormatter.FST, op_idxs::Vector{Int64})
    @ JuliaFormatter ~/.julia/packages/JuliaFormatter/xKNsr/src/align.jl:124
  [8] align_fst!(fst::JuliaFormatter.FST, opts::JuliaFormatter.Options)
    @ JuliaFormatter ~/.julia/packages/JuliaFormatter/xKNsr/src/align.jl:31
  [9] format_text(cst::CSTParser.EXPR, style::MinimalStyle, s::JuliaFormatter.State)
    @ JuliaFormatter ~/.julia/packages/JuliaFormatter/xKNsr/src/JuliaFormatter.jl:649
 [10] format_text(text::String, style::MinimalStyle, opts::JuliaFormatter.Options)
    @ JuliaFormatter ~/.julia/packages/JuliaFormatter/xKNsr/src/JuliaFormatter.jl:632
 [11] #format_text#238
    @ ~/.julia/packages/JuliaFormatter/xKNsr/src/JuliaFormatter.jl:604 [inlined]
 [12] #format_text#237
    @ ~/.julia/packages/JuliaFormatter/xKNsr/src/JuliaFormatter.jl:598 [inlined]
 [13] _format_file(filename::String; overwrite::Bool, verbose::Bool, format_markdown::Bool, format_options::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:style, :normalize_line_endings, :align_assignment), Tuple{MinimalStyle, String, Bool}}})
    @ JuliaFormatter ~/.julia/packages/JuliaFormatter/xKNsr/src/JuliaFormatter.jl:723
 [14] (::JuliaFormatter.var"#246#249"{Base.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:style, :normalize_line_endings, :align_assignment, :verbose), Tuple{MinimalStyle, String, Bool, Bool}}}})(formatted_file::Bool, file::String)
    @ JuliaFormatter ~/.julia/packages/JuliaFormatter/xKNsr/src/JuliaFormatter.jl:878
 ...

@domluna
Copy link
Owner

domluna commented Oct 7, 2022

yeah that's fine, it's mainly to just track down the file that's causing issues

@Moelf
Copy link
Author

Moelf commented Oct 7, 2022

right, that information is already available though, there's a @info telling us which file is the offender

@domluna
Copy link
Owner

domluna commented Oct 7, 2022

😅 - forgot that was recently added lol

@bramtayl
Copy link
Contributor

bramtayl commented Oct 8, 2022

A good start might be to add a more informative error if binop_idx is nothing:

binop_idx = findfirst(nn -> nn.typ === Binary, n.nodes)

@domluna
Copy link
Owner

domluna commented Oct 9, 2022

formats fine if binop_idx === nothing is skipped

Seems to be something to do with a macroblock for this particular error

@domluna
Copy link
Owner

domluna commented Oct 11, 2022

ok I have a PR which fixes the align_assignment issue #646

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

Successfully merging a pull request may close this issue.

3 participants