Open Bug 1397233 Opened 7 years ago Updated 6 years ago

Serializer should throw an error when the first TextElement of a Pattern contains leading whitespace

Categories

(L20n :: Python Library, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

People

(Reporter: stas, Unassigned)

References

Details

The parser ignores the leading whitespace in values. The following two snippets are AST-equal:

    foo = Foo
    foo =      Foo

As such it is not possible for an AST which is a result of parsing to contain Patterns whose first element is a TextElement with leading whitespace.

We should make this explicit in the Serializer to prevent hand-created AST from serializing to something they are not. I think the way to go is to throw an error.
No longer blocks: 1396580
Blocks: 1398723
This probably affects pontoon primarily. Matjaz, do you have an opinion?

In migrations, we already mark up leading and trailing whitespace in explicit expressions in Transform.pattern_of
Flags: needinfo?(m)
Pontoon doesn't hand-create ASTs, so I don't think it's affected by that.

It also parses and serializes strings that are changing through the source editor.
Flags: needinfo?(m)
You need to log in before you can comment on or make changes to this bug.