Skip to content

Commit 76c260e

Browse files
docs: document is_leaf and update internals section (#56)
PR #55 exported `is_leaf` with a docstring but did not reference it in the manual, so Documenter's `:missing_docs` check now fails on main. Add `is_leaf` to the API reference, and replace the outdated "uses Cassette internally" section with a description of the `code_typed`-based branch detection. Verified locally: `julia --project=docs docs/make.jl` builds cleanly. Co-authored-by: Chris Rackauckas (Claude) <accounts@chrisrackauckas.com>
1 parent 9431084 commit 76c260e

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
```@docs
44
hasbranching
5+
is_leaf
56
```

docs/src/index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ end # true
2828
end # false
2929
```
3030

31-
## This package uses Cassette internally?
31+
## How does this package work internally?
3232

33-
Yes, because this is how it's currently known how to be done. If you have an alternative
34-
implementation which uses the undocumented compiler plugins interface, we would happily
35-
accept the PR!
33+
`hasbranching` inspects the type-inferred but unoptimized IR of the function
34+
(via `code_typed(f, argtypes; optimize = false)`) and checks for `GotoIfNot`
35+
nodes, which represent value-dependent conditional branches. Constructs that do
36+
not introduce data-dependent control flow, such as `ifelse`, do not produce
37+
`GotoIfNot` nodes and are therefore reported as branch-free.
38+
39+
If a function produces a false positive because its branches are known to
40+
resolve at compile time, opt it out with [`is_leaf`](@ref).
3641

3742
## Contributing
3843

0 commit comments

Comments
 (0)