docs: Improved transpiler documentation#358
Merged
Merged
Conversation
Now clearly lists all (currently) supported operations, and gives an informative error when a non-supported function/operation is used, e.g.
R input: `y[1] <- median(x[1])`
✖ Failed to transpile:
✖ Unsupported function "median" in model block.
ℹ The model transpiler does not know how to convert "median" to Rust.
ℹ Supported functions and operators are:
• Grouping/structure: (, {, if, else, for, <-, =, [ ] (indexing)
• Arithmetic: +, -, *, /, ^
• Comparison: ==, !=, >=, <=, >, <
• Logical: &, |, !
• Math: abs, exp, sqrt, ln, log, log10, log2
• Trigonometric: sin, cos, tan, asin, acos, atan, atan2
• Hyperbolic: sinh, cosh, tanh, asinh, acosh, atanh
• Rounding: floor, ceiling, round, trunc
• Pmetrics helpers: get_e2
Siel
approved these changes
Jun 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the R-to-Rust model-block transpiler’s user-facing documentation and error reporting by explicitly cataloguing supported operators/functions and emitting a detailed cli_abort() message when unsupported syntax is encountered.
Changes:
- Added an in-file, categorized list of supported R functions/operators for model blocks.
- Introduced
supported_transpiler_ops()+abort_unsupported_op()to generate a more informative unsupported-operation error. - Updated
expr_to_rust()to use the new error helper instead of a genericstop().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+69
to
+74
| operators <- c( | ||
| ops$Arithmetic, ops$Comparison, ops$Logical, | ||
| "(", "{", "if", "else", "for", "<-", "=", "[ ]" | ||
| ) | ||
| is_operator <- op %in% operators | ||
| kind <- if (is_operator) "operator" else "function" |
Comment on lines
+368
to
369
| abort_unsupported_op(op) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now clearly lists all (currently) supported operations, and gives an informative error when a non-supported function/operation is used, e.g.