Skip to content

(call)

function calls

clojure
(call receiver? args?)

Where:

  1. receiver: callee expression (the foo in foo(), or use (mem ...) for value.method() calls) *
  2. args: arguments supplied to the call *

Matching:

  1. free function calls, e.g. foo()
  2. method calls, e.g. value.method()
  3. macro invocations, e.g. macro!(...)

Behavior

  • Macro invocations are matched by name only; argument matching is ignored for macros.
  • Bare (call) does not match macro invocations; provide a receiver to match them.

Examples

Find unwrap calls that can panic at runtime.

clojure
(call (mem unwrap))

Selects in lines { 1 } but not in { 2 }:

rust
let value = option.unwrap();
let value = option.expect("missing");

Find read_to_string calls that pass a literal manifest path.

clojure
(call (id read_to_string) (arg 1 (str /\.toml$/)))

Selects in lines { 1 } but not in { 2 }:

rust
let manifest = std::fs::read_to_string("Cargo.toml");
let data = std::fs::read_to_string(path);

Audit uses of include_str! for embedded assets.

clojure
(call (id include_str))

Selects in lines { 1 } but not in { 2 }:

rust
const BANNER: &str = include_str!("banner.txt");
let msg = format!("hi");

Arguments

receiver

• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
(:kind) (:ref) (:text) (call) (enum) (fun) (id) (mem) (num) (str) (:into) (:and) (:or) (:not) (:replace) (:capture)

args

(arg)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

Copyright © 2022-present Semantic Works, Inc.