Lambda and Variable Expressions and BoundExpressions - #9250
Closed
mhk197 wants to merge 2 commits into
Closed
Conversation
mhk197
force-pushed
the
mk/lambda-variables
branch
from
August 6, 2026 21:25
e9d99c4 to
7f9975b
Compare
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Lambda and Variable ExpressionsLambda and Variable Expressions and BoundExpressions
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
mhk197
force-pushed
the
mk/lambda-variables
branch
from
August 7, 2026 02:48
7f9975b to
e41b484
Compare
Contributor
Author
|
Superseded — reopening against |
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.
Adds lambdas and variables as
ExpressionVariants and implements the scope machinery to bind them.Binding:
Design notes
A lambda is bound by whoever knows its parameter types. They come from whatever applies it, so
Lambda::bindtakes them. That is the entry point a higher-order function will call with typesderived from its own arguments; here, tests call it directly.
BoundLambdais a struct, not aBoundKindvariant. A lambda has noDType, and everyBoundExpressionis guaranteed to have one. The function type is recorded structurally instead:param_dtypesis the argument side,body_dtype()the result side.Scopecarries frames, not a flat map. A flatname -> dtypemap cannot distinguish "thisbinder's own parameter" from "a name from an enclosing binder", which is what a capture check needs.
resolvereturns the dtype and the frame depth so that check is later a comparison rather than are-derivation.