Skip to content

transpile: Add Tagged wrapper to represent a potentially-unsafe expression - #2015

Draft
Rua wants to merge 2 commits into
immunant:masterfrom
Rua:unsafe-expr-wrapper
Draft

Rua wants to merge 2 commits into
immunant:masterfrom
Rua:unsafe-expr-wrapper

Conversation

@Rua

@Rua Rua commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Unlike WithStmts, this doesn't contain any statements, but represents an expression alone. I've made it the return type of any functions that return an unsafe expression (notably, transmute_expr), and refactored all the call sites around the new return type. I've also added a Flattenable trait which makes things like and_then more generic; the genericised version is named flat_map and is implemented for WithStmts too.

My intent here is for WithStmts to eventually lose its is_unsafe field altogether, and for WithStmts<Tagged<T>> to be used instead in that role. I haven't done that here, as it will require more refactoring throughout the codebase.

The name Tagged is not particularly great, I'll admit. But I couldn't really come up with anything better at the moment. I considered naming it Safety, Unsafe or MaybeUnsafe, but that ties it too strongly to that particular function. It's possible that more fields could be added to it later, if anyone thinks of any. (Edit: just thought of another potential use, indicating whether the expression has side effects)

@Rua
Rua force-pushed the unsafe-expr-wrapper branch from ced2f5c to 180d836 Compare September 16, 2026 17:41
@Rua
Rua force-pushed the unsafe-expr-wrapper branch from 180d836 to d5249fb Compare September 16, 2026 18:22
@Rua
Rua marked this pull request as draft September 26, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant