Skip to content

[Linting Rule] Undefined Symbol

github-actions[bot] edited this page Jul 6, 2026 · 1 revision

This document was generated from 'src/documentation/wiki-linter.ts' on 2026-07-06, 04:19:23 UTC presenting an overview of flowR's linter (v2.10.10). Please do not edit this file/wiki page directly.

Undefined Symbol [overview]

bug experimental

This rule is a over-approximative rule.

Flags calls to functions that are neither defined locally, a known builtin, nor exported by a loaded package.
This linting rule is implemented in src/linter/rules/undefined-symbol.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The undefined-symbol rule accepts the following configuration options:

Examples

undefined_helper(42)

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "undefined-symbol",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (0 ms)
   ╰ Undefined Symbol (undefined-symbol):
       ╰ uncertain:
           ╰ Call to undefined_helper at 1.1-20
       ╰ Metadata: totalCalls: 1, searchTimeMs: 0, processTimeMs: 0
All queries together required ≈0 ms (1ms accuracy, total 0 ms)

Show Detailed Results as Json

The analysis required 0.3 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "linter": {
    "results": {
      "undefined-symbol": {
        "results": [
          {
            "certainty": "uncertain",
            "name": "undefined_helper",
            "involvedId": 3,
            "loc": [
              1,
              1,
              1,
              20
            ]
          }
        ],
        ".meta": {
          "totalCalls": 1,
          "searchTimeMs": 0,
          "processTimeMs": 0
        }
      }
    },
    ".meta": {
      "timing": 0
    }
  },
  ".meta": {
    "timing": 0
  }
}

Additional Examples

These examples are synthesized from the test cases in: test/functionality/linter/lint-undefined-symbol.test.ts

Test Case: undefined function is flagged

Given the following input:

foo()

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Uncertain, name: 'foo', loc: [1, 1, 1, 5] }]

See here for the test-case implementation.

Test Case: locally defined function is not flagged

Given the following input:

foo <- function() 1
foo()

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: builtin is not flagged

Given the following input:

print("hi")
c(1, 2)

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Test Case: only the undefined call is flagged

Given the following input:

g <- function() 1
g()
h()

We expect the linter to report the following:

[{ certainty: LintingResultCertainty.Uncertain, name: 'h', loc: [3, 1, 3, 3] }]

See here for the test-case implementation.

Test Case: not flagged when an unknown library is loaded

// an unknown loaded library disables the rule: its exports might define the symbol

Given the following input:

library(somePkg)
foo()

We expect the linter to report the following:

* no lints

See here for the test-case implementation.

Clone this wiki locally