Skip to content

madlib format moves comments around in a way that is confusing #196

@brekk

Description

@brekk

What version of Madlib are you running?

0.26.3

How is Madlib installed on your system?

None

What were you trying to do?

I have code that I'm updating in ensign:

parseFlags :: List String -> List Flag
export parseFlags = 
pipe(
  map(_splitJointFlags),
  (steps) => List.reduce(
    (agg, curr) => ({ prev: Just(curr), stack: _updateStack(agg.stack, agg.prev, curr) }),
    { stack: [], prev: List.nth(0, steps) },
    // stuff an empty value at the end so we process all entries
    List.append([], List.tail(steps)),
  ),
  .stack,
)

When I run madlib format, it moves the comment around in a way that makes it very unhelpful

What did you expect to happen?

Don't move comments around

What actually happened?

parseFlags :: List String -> List Flag
export parseFlags = pipe(
  map(_splitJointFlags),
  (steps) => List.reduce(
    (agg, curr) => (
      {
        prev: Just(curr),
        // stuff an empty value at the end so we process all entries
        stack: _updateStack(agg.stack, agg.prev, curr),
      }
    ),
    { stack: [], prev: List.nth(0, steps) },
    List.append([], List.tail(steps)),
  ),
  .stack,
)

This is how it looks after formatting, which ends up being a wholly unrelated bit of code

Logs

Code Targets

No response

Environment details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions