Skip to content

Conversation

@dhedey
Copy link
Owner

@dhedey dhedey commented Sep 29, 2025

No description provided.

@dhedey dhedey marked this pull request as draft September 29, 2025 14:37
dhedey added 28 commits October 9, 2025 15:18
This PR implements a comprehensive scoping and binding system for the preinterpret macro language, enabling compile-time analysis of variable lifetimes and ownership. The implementation creates scopes and bindings during parse time, resolves variable references to bindings, and determines if a binding is final to eliminate unnecessary .take_owned() calls.

Key changes:

* Adds scope and control flow analysis at parse time to track variable definitions, references, and their final uses
* Removes the need for explicit .take_owned() calls by automatically detecting when a variable reference is its final use
* Introduces a two-pass parsing system: initial parsing followed by control flow analysis
* Adds support for #{ } embedded statement blocks in stream literals that execute in the parent scope
claude and others added 30 commits December 11, 2025 13:17
…stedValue>

- Update all RequestedOwnership::map_from_* methods to:
  - Take Spanned<X> instead of (X, SpanRange) for consistent span tracking
  - Return Spanned<RequestedValue> instead of just RequestedValue
- Update all ArgumentOwnership::map_from_* methods similarly
- Update all callers to wrap values in Spanned and extract .0 where needed
- Update evaluator context methods to work with Spanned return values

This continues the pattern of keeping spans together with values for
better error messages and cleaner API boundaries.
…fields

Remove span_range fields from LateBoundOwnedValue and LateBoundSharedValue
that were incorrectly added during this PR. Instead, the span is now carried
externally via Spanned<LateBoundValue> through the variable resolution chain:

- VariableState::resolve returns Spanned<LateBoundValue>
- Interpreter::resolve returns Spanned<LateBoundValue>
- VariableReference::resolve_late_bound returns Spanned<LateBoundValue>
- map_from_late_bound methods take Spanned<LateBoundValue>
- resolve() method moved from LateBoundValue to Spanned<LateBoundValue>
…ile loop

- Change WhileExpression::evaluate to use a while loop instead of loop
- Update context.evaluate to take closure returning Spanned<RequestedValue>
- Update context.return_argument_value to take Spanned<ArgumentValue>
- Update context.return_returned_value to take Spanned<ReturnedValue>
- Update context.return_value to take Spanned<T>
- Update context.return_not_necessarily_matching_requested to take Spanned
- Add resolve_spanned method to TypeProperty
- Make ParseTemplateLiteral implement Evaluate trait
- Update all callers to use evaluate_spanned and wrap values in Spanned
… bugs

- Make enable(span_range) methods on base types (Mutable, Shared, CopyOnWrite)
  pub(crate) for internal use by Spanned<ArgumentValue>::enable()
- Spanned<T>::enable() delegates to inner type's enable(span_range)
- Fix map_from_shared_with_error_reason to take Spanned<SharedValue> and use
  try_transparent_clone instead of infallible_clone
- Fix map_from_mutable_inner to use try_transparent_clone for late-bound values
  instead of direct clone
- Add transparent_clone methods to Spanned<Shared<Value>> and Spanned<Mutable<Value>>
- Make MUTABLE_ERROR_MESSAGE and SHARED_ERROR_MESSAGE pub(crate)
- Add into_owned_transparently method to CopyOnWrite<Value> that properly
  handles SharedWithTransparentCloning by using try_transparent_clone
- Add convenience method on Spanned<CopyOnWrite<Value>>
- Fix map_from_copy_on_write in ArgumentOwnership to use into_owned_transparently
  instead of incorrectly using into_owned_infallible

This fixes a bug where transparent cloning semantics were being bypassed
when converting CopyOnWrite values to owned values.
…nmFvMjZnteoWNkdm6

Refactor Span Ranges

Span ranges get moved out to a Spanned<X> instead of being internal to value wrappers.

This is the first step towards allowing us to sensibly work with / resolve a Shared<T> for T != Value, which will unblock us to pass sub-values into closures, and unblock the functions/closures mini-project.
…rals

feat: Add back concatenated literals
…am-literal-misparse

feat: Add clarification for %xyz[] misparse
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.

3 participants