~/bend-docscommunity

src/rules/correctness/twice.bend checks

raw source on the hub · import 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/rules/correctness/twice.bend as Twice

rule twice: a list pattern in a def that calls itself, opening with the same literal twice (case 10 <> 10 <> _:, case Con{'a', Con{'a', t}}:). The checker hangs on it (pi-bend BEND-018, b6a83a52; bend 2.0.16 still does). Only the opening pair was seen to hang: 10 <> 11 <> 10, _ <> 10 <> 10 and 10 <> 11 <> 11 check at once, and so does the same pattern in a def that does not recurse. Match one element per step, with a state. A def recurses when its body calls it, name(..): a parameter or a value named like the def is not a call. Only a case's first match column is read: a list pattern in a later column of match a b: is not.

9 imports
import Base
import ../../src.bend as Src
import ../../finding.bend as F
import ../../syntax/lex.bend as Lex
import ../../syntax/tree.bend as Tree
import ../../syntax/bind.bend as Bind
import ../../lazy/lazy.bend as Lazy
import ../tokens.bend as T
import ../calls.bend as Calls

Definitions

def tail source · line 32 · raw

@pat:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node

the rest of a list pattern after its first element

def same source · line 43 · raw

@aa:Maybe<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> @bb:Maybe<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> @+path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>

a finding at the second literal when it repeats the first

def arm source · line 54 · raw

@+pat:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> @+path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>

a case statement's pattern, checked

def walk source · line 58 · raw

@nn:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> @+path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>

every case statement under a recursive def, at any depth

def check.def source · line 70 · raw

@mm:Maybe<&2, String> -> @+body:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> @path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>

a def's body, when it calls itself

def check.go source · line 77 · raw

@root:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> @+path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>

def check source · line 87 · raw

@ss:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/src.Src -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>

the rule