~/bend-docscommunity

bolt/rules/correctness/pick.bend fails

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/correctness/pick.bend as Pick

rule pick: a def calls itself in a branch of a Bool.pick. Bool.pick is a function, so both branches are evaluated whatever the condition. In both branches, two recursive calls a step is 2^n work where one was meant (a per-token scan that took 20 s this way took 20 ms as one pass): bind the call once above the pick (+more = go(rest)) and pick between x <> more and more. In one branch, the recursion runs even when the other branch was the answer: a search never stops early and walks the whole input (portal-bend's get, bendoom's sorted insert). Match on the Bool instead, in a helper that takes it as a parameter. A pick nested in a branch of one already reported is not reported again.

6 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 ../calls.bend as Calls