Skip to content

Extraneous return statement added to map / mapreduce statements #961

@dehann

Description

@dehann

There might be a bug with formatter, specifically the addition of an extraneous return statement to particular kind of do ... end statements, such as map / mapreduce -- e.g. this:

function somescope()
  ...

  # seems like perfectly good code, but...
  need_this = map(arr) do a
    util(...)
  end

  return val
end

is changed by formatter into code with a problem like this:

function somescope()
  ...

  need_this = map(arr) do a
    # oops, now there is a return that does not belong
    return util(...)
  end

  return val
end

This extraneous return now terminates the somescope prematurely. I haven't used Juliaformatter that much yet but hope this example shows the potential issue well enough. My guess is the logic for formatting a localized scope begin ... end statement (i.e. checking for return) is maybe over zealous on something like the map do example.

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