Skip to content

Issue with parents and constructors with arguments #26

@gilramir

Description

@gilramir

I'm not sure if there are 1 or 2 issues here.

  1. A constructor with arguments is accepted without parens; should this be a syntax error?
  2. Nested parents are dropped from the AST

Has parens

module Example exposing ( foo )

setStatus1 : Int -> Response -> Response
setStatus1 statusCode (Response response) =
    Response { response | status = statusCode }

Produces this ctor in the AST:

              {
                "start": {
                  "row": 4,
                  "col": 24
                },
                "end": {
                  "row": 4,
                  "col": 41
                },
                "value": {
                  "type": "ctor",
                  "name": {
                    "start": {
                      "row": 4,
                      "col": 24
                    },
                    "end": {
                      "row": 4,
                      "col": 32
                    },
                    "value": "Response"
                  },
                  "arg": {
                    "start": {
                      "row": 4,
                      "col": 33
                    },
                    "end": {
                      "row": 4,
                      "col": 41
                    },
                    "value": {
                      "type": "var",
                      "name": "response"
                    }
                  }
                }
              }

No parens

Without parens:

module Example exposing ( foo )

setStatus2 : Int -> Response -> Response
setStatus2 statusCode Response response =
    Response { response | status = statusCode }

produces the same AST (with small changes in a few token columns)

Nested parens

Unnecessary extra parens:

module Example exposing ( foo )

setStatus2 : Int -> Response -> Response
setStatus2 statusCode ((Response response)) =
    Response { response | status = statusCode }

Also produces the same AST, modulo token column positions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions