Skip to content

Bug in comment parsing in route definitions #1886

@parsonsmatt

Description

@parsonsmatt

Comments mess up the parsing of routes. Consider this block:

/nest/ NestR !NestingAttr:

  /spaces      SpacedR   GET !NonNested

  /nest2 Nest2:
    /           GetPostR  GET POST
    /get        Get2      GET
    /post       Post2         POST
--    /#Int       Delete2            DELETE
  /nest3 Nest3:
    /get        Get3      GET
    /post       Post3         POST
--    /#Int       Delete3            DELETE

The code generator should produce this as a ResourceParent with a leaf child SpacedR and two ResourceParent children, one for Nest3 and Nest2 . Instead, the comment starting at beginning-of-line causes this to parse Nest3 inside of Route Hierarchy.

It is likely that fixing this may cause significant downstream bugs and behavioral problems by changing the structure of the generated routes to match what is written in the file. As an example, the current actual URL structure of the Route Hierarchy will accept /nest3/get and /nest/nest2/get. Existing clients will be using this, and since all the typed route stuff is type-checking things fine, this will Work, even if it is misleading to what people intended.

I would expect people to notice bugsin the case like /admin/#Int AdminR:, since the YesodDispatch would not generate routes that actually have the Int parameter - but still.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions