language/forward_reference.bend checks
raw source on the hub · import bend-lint-rules@0.3.3.0/language/forward_reference.bend as Forward_reference
language/forward_reference: live code that uses a definition of its file defined below it.
Heuristics: Bend checks definitions in file order, and one below is still a bodiless claim, so live
code cannot use it: the check fails with "a filled definition". So two definitions cannot call each
other. Types and equations are dead code, so they may name any definition, and an @unsafe
definition (def f?) may use any. Bend's checker stops at its first error; this rule reports every
such use at once. A definition used as a type argument of a call is dead too, but the rule cannot
tell such an argument from a live one.
4 imports
import Base import bend-lint-api@0.3.3.0/linter/api/impl.bend as LintImpl import bend-lint-api@0.3.3.0/linter/api/spec.bend as Lint import bend-lint-api@0.3.3.0/shared.bend as Shared
Types
type Place source · line 17 · raw
Data
A definition of the file: where it is among the file's nodes, and its name as written.
Place@at:U32 -> @name:String -> Place
type User source · line 22 · raw
Data
What judging the uses in one definition reads: where each definition of the file is, by the name the check gives it; and where the definition is, with its name.
User@places:Map<&2, Maybe<&2, Place>> -> @at:U32 -> @name:String -> User
Definitions
def message source · line 27 · raw
@+used:String -> @+user:String -> String
Functions =========
def places source · line 38 · raw
@nodes:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Node> -> @+at:U32 -> @out:Map<&2, Maybe<&2, Place>> -> Map<&2, Maybe<&2, Place>>
Where each definition among nodes, the file's, is, from at, onto out.
def below source · line 53 · raw
@hit:Bool -> @path:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Above> -> @used:String -> @user:String -> @span:Maybe<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Span> -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
The finding about a use of used from user, if used is below it. Whether the use is live is asked only then:
&& computes both sides.
def judged source · line 66 · raw
@path:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Above> -> @place:Maybe<&2, Place> -> @user:User -> @span:Maybe<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Span> -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
def User.places source · line 78 · raw
@user:User -> Map<&2, Maybe<&2, Place>>
def use source · line 83 · raw
@+user:User -> @+path:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Above> -> @+node:0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Node -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
def users source · line 91 · raw
@nodes:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Node> -> @+places:Map<&2, Maybe<&2, Place>> -> @+at:U32 -> @out:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding> -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
The findings in the definitions among nodes, from at, onto out. An @unsafe definition may use any.
def run source · line 121 · raw
@+here:0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Here -> 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Ask(List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>)
def rule source · line 125 · raw
0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Rule