Stream: contributing

Topic: 🚨 Whitespace application and whitespace - breaking change! 🚨


view this post on Zulip Anthony Bullard (Dec 27 2024 at 15:54):

Seems like the problem is all the way in pretty_assertions

view this post on Zulip Anthony Bullard (Dec 27 2024 at 15:56):

It might that somewhere a \r is being inserted

view this post on Zulip Anthony Bullard (Dec 27 2024 at 16:09):

I know that @Joshua Warner or @Brendan Hansknecht will come in and tell me I'm doing something terribly silly and obviously wrong - but I can't see it. And I'd like to keep these tests

view this post on Zulip Anthony Bullard (Dec 27 2024 at 16:09):

I'll try similar in snapshots and see if we get the same issue

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:35):

Looking into snapshots, I'm noticing that this is valid:

N<l(r*N)

And that may cause some issues for keeping WSA and PNC together.

The only solution I see is if an ident_seq is followed by a parenthensized expression or tuple and there is no SpacesBefore, we convert. But even that changes the semantics of code like this.

Anyone have a clue for how to disambiguate the two?

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:37):

Right now this is parsed as:

N < l (r * N)

With any reasonable interpretation of PNC, there it would be parsed as:

N < l(r * N)

as in (with WSA):

N < (l (r * N))

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:38):

Basically, we would have to have a backwards incompatible change where application would require a space between an ident subsequent expressiosn

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:38):

I don't think there's a way around that

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:39):

Which actually is surprising that we allowed WSA without the err, whitespace

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:39):

It's almost always better to parse maximally and give errors rather than fail parsing IMO

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:39):

And instead, i guess, treated the end of an ident and the beginning of a non-ident expr as "whitespace"

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:39):

Unless there are perf implications

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:40):

I think you should parse the grammar and bail as sson as you get something you don't expect

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:41):

You can continue parsing and add an error report

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:41):

But I personally prefer strictness in things like whitespace

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:42):

I think I'd prefer Richard to weight in here, this is probably an impactful change

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:46):

Anthony Bullard said:

I think you should parse the grammar and bail as sson as you get something you don't expect

When you say bail, do you mean "fail parsing the rest of the module" or "fail this top-level node, i.e. the function body"

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:46):

The latter can be a good user experience, but the former always sucks

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:46):

Fail just the def

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:46):

Okay, great

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:47):

Yeah, that's seemingly what Joshua Warner has been trying to do

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:47):

We want to be robust for the LSP and other tools

view this post on Zulip Sam Mohr (Dec 27 2024 at 19:47):

And he's got a lot more of a knowledge base here than I do

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:47):

I always built the former because they were early/hobby parsers, but the latter is the way

view this post on Zulip Notification Bot (Dec 27 2024 at 19:51):

24 messages were moved here from #contributing > Parens and commas work by Anthony Bullard.

view this post on Zulip Anthony Bullard (Dec 27 2024 at 19:52):

For context, this was to make this a top-level thing to debate

view this post on Zulip Anthony Bullard (Dec 28 2024 at 12:48):

It doesn't seem like there is much of any concerns with this change, so I'll take silence as a Go Ahead

view this post on Zulip Joshua Warner (Dec 28 2024 at 13:48):

I don’t think it’s a problem to change semantics of tests (particularly snapshot tests)… so long as those tests aren’t properly formatted. I.e. changes are fine so long as they won’t affect code that has previously come out of the formatter.

view this post on Zulip Anthony Bullard (Dec 28 2024 at 13:48):

:+1:


Last updated: Jul 06 2025 at 12:14 UTC