Skip to content

Callable structures split over multiple lines break parsing. #153

@dcelisgarza

Description

@dcelisgarza

I just saw the JuliaCon talk and it made me excited to try the formatter. However, it ended up breaking some code, I don't have any insight into how to fix it. It happens when structs have long names and types, and then these structs can be called with separate arguments.

For example this code will not run. Something like this happens when I run runic on my code for some functions. The function is not split by in this way by JuliaFormatter.jl

abstract type VeryLongAbstractAlgorithmNameForProcessOne end
abstract type VeryLongAbstractAlgorithmNameForProcessTwo end

struct VeryLongConcreteAlgorithmNameForProcessOneA <: VeryLongAbstractAlgorithmNameForProcessOne end
struct VeryLongConcreteAlgorithmNameForProcessOneB <: VeryLongAbstractAlgorithmNameForProcessOne end

struct VeryLongConcreteAlgorithmNameForProcessTwoA <: VeryLongAbstractAlgorithmNameForProcessTwo end
struct VeryLongConcreteAlgorithmNameForProcessTwoB <: VeryLongAbstractAlgorithmNameForProcessTwo end


struct MyStructWithQuiteALongAndVeryDescriptiveName{
    T1 <:VeryLongAbstractAlgorithmNameForProcessOne,
    T2 <:VeryLongAbstractAlgorithmNameForProcessTwo,
}
    a::T1
    b::T2
end

function (
        ::MyStructWithQuiteALongAndVeryDescriptiveName{
            <:VeryLongConcreteAlgorithmNameForProcessOneA,
            <:VeryLongConcreteAlgorithmNameForProcessTwoA
        },
    )
    (
        a::AbstractVector, b::AbstractVector, c::AbstractVector,
        d::AbstractMatrix, e::AbstractMatrix, d::AbstractMatrix,
    )

...

end

The solution is to keep it like so:

function (
        ::MyStructWithQuiteALongAndVeryDescriptiveName{
            <:VeryLongConcreteAlgorithmNameForProcessOneA,
            <:VeryLongConcreteAlgorithmNameForProcessTwoA
        },
    )(
        a::AbstractVector, b::AbstractVector, c::AbstractVector,
        d::AbstractMatrix, e::AbstractMatrix, d::AbstractMatrix,
    )

I'd love to be able to use runic, I find the style much nicer than anything i've managed to hack together using JuliaFormatter.jl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions