Stream: bugs

Topic: Pipe into method


view this post on Zulip Jonathan (Sep 01 2026 at 15:58):

When a value is piped into a method, such as shown below, the error my_const.<method_name> does not exist is given. Was it decided that you shouldn't be able to pipe into methods?

    my_const = []

    _ = my_const.concat([1, 2, 3]) # Ok
    _ = [1, 2, 3] |> my_const.concat # Not Ok!
    # Error: (`my_const.concat` does not exist)

    _ = my_const.append(1) # Ok
    _ = 1 |> my_const.append # Not Ok!

    _ = my_const.is_eq([1, 2]) # Ok
    _ = [1, 2] |> my_const.is_eq # Not Ok!

view this post on Zulip Richard Feldman (Sep 01 2026 at 15:59):

syntactically, my_const.concat always means, without exception, "access the field concat on a record named my_constant"

view this post on Zulip Jonathan (Sep 01 2026 at 15:59):

Ah, so brackets needed?

view this post on Zulip Richard Feldman (Sep 01 2026 at 15:59):

and my_const.concat() is always syntactically a method call

view this post on Zulip Richard Feldman (Sep 01 2026 at 15:59):

yep!

view this post on Zulip Jonathan (Sep 01 2026 at 15:59):

It's just the formatter is currently removing the brackets

view this post on Zulip Richard Feldman (Sep 01 2026 at 16:00):

ah then that's a formatter bug we should fix! :smile:

view this post on Zulip Richard Feldman (Sep 01 2026 at 16:00):

mind opening a gh issue for it?

view this post on Zulip Jonathan (Sep 01 2026 at 16:00):

No prob

view this post on Zulip Jonathan (Sep 01 2026 at 16:04):

#11045

view this post on Zulip Jonathan (Sep 01 2026 at 16:05):

Separately, should you be able to pipe into a method of a literal? E.g.

_ = [1,2,3].concat([4,5,6])

This gives a parser error. It looks a bit odd and is uncommon but sometimes I find it nicer to read at the start of a longer pipeline.

view this post on Zulip Richard Feldman (Sep 01 2026 at 16:12):

yes, that should work! definitely also worth a gh issue :smile:

view this post on Zulip Jonathan (Sep 01 2026 at 16:19):

#11046


Last updated: Sep 03 2026 at 15:16 UTC