ennocramer / floskell

Floskell is a flexible Haskell source code pretty printer.
BSD 3-Clause "New" or "Revised" License
178 stars 22 forks source link

Ridiculous memory usage on formatting particular operator combinations #80

Open pe200012 opened 4 months ago

pe200012 commented 4 months ago

version info:

> floskell --version
floskell 0.10.7

config.json:

{
    "extensions": [],
    "fixities": [],
    "formatting": {
        "align": {
            "case": true,
            "class": false,
            "import-module": true,
            "import-spec": true,
            "let-binds": true,
            "limits": [
                10,
                25
            ],
            "matches": true,
            "record-fields": true,
            "where": true
        },
        "group": {
            "[ in type": {
                "force-linebreak": false,
                "linebreaks": "none",
                "spaces": "both"
            },
            "default": {
                "force-linebreak": false,
                "linebreaks": "after",
                "spaces": "both"
            }
        },
        "indent": {
            "app": "indent-by 4",
            "case": "indent-by 4",
            "class": "indent-by 4",
            "deriving": 4,
            "do": "indent-by 4",
            "export-spec-list": "indent-by 4",
            "if": "indent-by 4",
            "import-spec-list": "align",
            "let": "indent-by 4",
            "let-binds": "indent-by 4",
            "let-in": "indent-by 4",
            "multi-if": "indent-by 4",
            "onside": 4,
            "typesig": "align",
            "where": 2,
            "where-binds": "indent-by 2"
        },
        "layout": {
            "app": "try-oneline",
            "con-decls": "try-oneline",
            "declaration": "try-oneline",
            "export-spec-list": "try-oneline",
            "if": "vertical",
            "import-spec-list": "try-oneline",
            "infix-app": "try-oneline",
            "let": "vertical",
            "list-comp": "try-oneline",
            "record": "try-oneline",
            "type": "try-oneline"
        },
        "op": {
            ",": {
                "force-linebreak": false,
                "linebreaks": "before",
                "spaces": "after"
            },
            ". in type": {
                "force-linebreak": false,
                "linebreaks": "after",
                "spaces": "after"
            },
            "default": {
                "force-linebreak": false,
                "linebreaks": "before",
                "spaces": "both"
            },
            "record": {
                "force-linebreak": false,
                "linebreaks": "after",
                "spaces": "after"
            }
        },
        "options": {
            "align-let-binds-and-in-expr": true,
            "align-sum-type-decl": true,
            "decl-no-blank-lines": [],
            "flexible-oneline": true,
            "preserve-vertical-space": false,
            "sort-import-lists": true,
            "sort-imports": true,
            "sort-pragmas": true,
            "split-language-pragmas": true
        },
        "penalty": {
            "indent": 1,
            "linebreak": 100,
            "max-line-length": 100,
            "overfull": 10,
            "overfull-once": 200
        }
    },
    "language": "Haskell2010",
    "style": "base"
}

MWE:

-- A.hs
module A where

someMethod
    = someF <$> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1
    <*> id 1

Invoking floskell A.hs eats up all of my 32G memory, and won't terminate.

The id 1 can be any other expression in the form of app x1 x2..., in order to trigger this bug.

Any help is appreciated!