elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.51k stars 657 forks source link

Compiler error: Mutable.hs:703: index out of bounds (3,3) #2152

Open matsjoyce opened 3 years ago

matsjoyce commented 3 years ago

Quick Summary:

Compiler crashes with the error:

Compiling ...elm: ./Data/Vector/Generic/Mutable.hs:703 (modify): index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at ./Data/Vector/Internal/Check.hs:87:5 in vector-0.12.0.3-c437ec060b3fdd8eecce3c5fd7ada7fe6d6f6ed56dbc08f484769fe155c657df:Data.Vector.Internal.Check

SSCCE

Main.elm:

module Main exposing (..)

import Material.List.Item as ListItem
import Material.Checkbox as Checkbox

x data =
    let
        func item =
            ListItem.listItem
                (ListItem.config
                    |> ListItem.setSelected (if Just item.id == data.x then 1 else 2)
                )
                [ Checkbox.checkbox
                    (Checkbox.config
                        |> Checkbox.setState (if item.id == data.x then 1 else 2)
                    )
                ]
    in
    Nothing

elm.json:

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "aforemny/material-components-web-elm": "6.0.0",
            "elm/browser": "1.0.2",
            "elm/core": "1.0.5",
            "elm/html": "1.0.0"
        },
        "indirect": {
            "elm/json": "1.1.3",
            "elm/svg": "1.0.1",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

Additional Details

Duplicate of #2148. In this case the crash can be avoided by changing line 15 to |> Checkbox.setState (if Just item.id == data.x then 1 else 2).

github-actions[bot] commented 3 years ago

Thanks for reporting this! To set expectations:

Finally, please be patient with the core team. They are trying their best with limited resources.