~/bend-docscommunity

src/rules/table.bend checks

raw source on the hub · import bolt@1.57.0.0/src/rules/table.bend as Table

src/rules/table: what a fixed table is, for index. A fixed table is a literal list, an array, or List.replicate / Array.new / List.range with a constant count, written inline, defined beside the loop, or held by the let of that name in scope; a let reaches the statements after it and the blocks under them, not a sibling case arm, and a later let of the name to anything else ends it. index leaves a get of one alone. This was the table rule (U008), retired: it had no public hits; hit still builds the finding that rule gave, which index reads only as "a fixed table". Pure.

6 imports
import Base
import ../finding.bend as F
import ../syntax/lex.bend as Lex
import ../syntax/tree.bend as Tree
import ./calls.bend as Calls
import ../lazy/lazy.bend as Lazy

Definitions

def literal source · line 17 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> Bool

is the chain exactly one number?

def top_has source · line 25 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+want:String -> Bool

a top-level token of this text, not one nested in a group

def array_sized source · line 38 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> Bool

[v : T*n] or [v : T^d], and the size is a number

def lone_num source · line 53 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> Bool

the chain is exactly one number

def range_count source · line 61 · raw

@as:List<&2, 0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node> -> Bool

List.replicate / Array.new count at argument 2; List.range at the end

def built_call source · line 71 · raw

@+t:String -> @kids:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> Bool

a constant-size constructor, not a length taken from the data

def built source · line 77 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> Bool

a list literal, a sized array, or a constant-size constructor

def call_name source · line 88 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> String

the chain is exactly this call's name, with no arguments that matter: name()

def lone_name source · line 97 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> String

the chain is exactly one lowercase name

def key source · line 105 · raw

@+t:String -> @+line:U32 -> @+col:U32 -> String

one use of a name, told apart from its other uses by where it stands

def lone_key source · line 109 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> String

the chain is exactly one lowercase name: that use's key

def owns source · line 118 · raw

@+n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+fixed:List<&2, String> -> Bool

the list argument is a fixed table: inline, a use of a let that holds one, or name() / name for a table def of the file

def bind_bad source · line 128 · raw

@+bad:Bool -> @+nm:String -> String

one plain name before =, when the pattern is not a destructure

def bind_at source · line 136 · raw

@+seen:Bool -> @+bad:Bool -> @+nm:String -> String

one plain name before =, when there is one

def bind_name source · line 144 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+seen:Bool -> @+bad:Bool -> @+nm:String -> String

the one plain name a statement binds, or empty

def bind_rhs source · line 160 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> 0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node

the right-hand side: the chain after a statement's top-level =

def drop source · line 170 · raw

@live:List<&2, String> -> @+nm:String -> List<&2, String>

the names in scope without this one

def rebind source · line 179 · raw

@+nm:String -> @+tab:Bool -> @+live:List<&2, String> -> List<&2, String>

after a let of nm: it holds a table only when this binding is one

def use_at source · line 185 · raw

@+t:String -> @+line:U32 -> @+col:U32 -> @+live:List<&2, String> -> @+acc:List<&2, String> -> List<&2, String>

a name use joins the keys when the let in scope for it holds a table

def lets source · line 191 · raw

@n:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+live:List<&2, String> -> @acc:List<&2, String> -> List<&2, String>

the keys of every name use under the node whose binding in scope is a table: a let reaches the statements after it and their bodies, not an enclosing block or a sibling arm, and a later let of the name replaces it

def mod_one source · line 206 · raw

@body:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+name:String -> @+acc:List<&2, String> -> List<&2, String>

a def whose body is one fixed table

def modules source · line 214 · raw

@ds:List<&2, 0xf70fc6a217b89edfba89174d2aa39455/src/rules/calls.Def> -> @acc:List<&2, String> -> List<&2, String>

defs of this file whose body is one fixed table

def scope source · line 223 · raw

@body:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+mods:List<&2, String> -> List<&2, String>

fixed tables visible in this def: the file's table defs by name, and each use of a let whose binding in scope is a table, by its key

def cite source · line 227 · raw

@+get:Bool -> @+path:String -> @+line:U32 -> @+col:U32 -> @+len:U32 -> 0xf70fc6a217b89edfba89174d2aa39455/src/finding.Finding

the finding for a get or a set

def hit source · line 237 · raw

@+open:Bool -> @+t:String -> @kids:0xf70fc6a217b89edfba89174d2aa39455/src/syntax/tree.Node -> @+fixed:List<&2, String> -> @+path:String -> @+line:U32 -> @+col:U32 -> List<&2, 0xf70fc6a217b89edfba89174d2aa39455/src/finding.Finding>

a get or a set of a fixed table at a computed index