Error codes · Effects

PW0401

forbidden_effect

The program must hold to this: some effects are not permitted where a declaration runs, whatever it declares.

A program the compiler refuses with it

Refused: PW0401
module menu

type Item = Item { name: String }

fn items() -> List<Item> !{ database.read<Item> }
    host "shop:data/items#all"

view Menu() !{} {
    let all = items()
    <ul>
        {#each all as item (item.name)}
            <li>{item.name}</li>
        {/each}
    </ul>
}

From Rendering that reaches the database, in Why Pleris. A test holds the guide's examples to the compiler.

Refused: PW0401
module shop.head

type Item = Item { name: String }

fn items() -> List<Item> !{ database.read<Item> }
    host "shop:data/items#all"

view Menu() !{} {
    <ul>
        {#each items() as item (item.name)}
            <li>{item.name}</li>
        {/each}
    </ul>
}

From Where pw check stops, in Pages. A test holds the guide's examples to the compiler.

Reading the diagnostic

pw check prints the code in brackets, [PW0401], with the sentence above and the place in your program. Errors and diagnostics explains how to read one, and every code is listed with its rule.