Repository navigation
Conversation
FLATTEN_AS_FIELDOP_ARGS named the let variable binding a flattened tuple argument
__ct_flat_remapped_{i}, with a counter restarting at 0 on every application. Flattening a
nested tuple argument inside a let that survived the previous flattening rebound the same
name and captured the outer references.
A program body like domain={E: (d.edges.lb, d.edges.ub)} failed on every compiled backend
because ProgramLowering had no visit_Attribute.
|
🤖 Written by an agent on behalf of @havogt |
A subscript on a tuple program argument, e.g. d[1] as a field operator argument or d[0][1] as a domain bound, was typed as the whole tuple and nested subscripts were rejected, as program_ast.Subscript only modelled slicing an output field.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
⚙️ Agent run details
|
Reject non-literal, out-of-range, negative and bool tuple indices, integer indexing of dataclass collections and element access on closure variables with a DSLError, and look up named-collection attributes by key, so that fields named like attributes of the type spec (e.g. 'keys') resolve.
|
Note Advisory review by opencode 2.2.7 ( SummaryThis PR makes named collections / tuples usable as program arguments: Findings
Nits
Questions
|
…programs Subscripting a scalar or slicing a field passed as a field operator input got through type deduction and failed on an assert in lowering. Also resolve the NamedTuple/dataclass distinction for classes defined in a function, which pkgutil can not resolve by name.
Attribute access on an enum or FrozenNamespace closure variable in a program body is folded to a constant, as in field operators. It previously worked only in embedded execution.
…llow-up Keep only the index checks for tuple subscripts and the rejection of subscripted scalars here. Key-based attribute lookup, folding of enum attributes, rejecting dataclass indexing, closure-variable element access and sliced inputs move to a separate PR.
| node.location, | ||
| f"Tuples need to be indexed with literal integers in " | ||
| f"[0, {len(value.type.types)}), got '{node.slice_}'.", | ||
| ) |
There was a problem hiding this comment.
or do we want to have the wrap around semantics?
…wn PR This reverts commit 3969b84. The fix now lives on tehrengruber/collapse-tuple-remapped-arg-capture, which names the remapped arguments with unique_symbol instead of uids.
Fixes for named collections and tuples passed as program arguments:
domain={E: (d.edges.lb, d.edges.ub)}) was not lowered:ProgramLoweringgets avisit_Attribute, lowering totuple_getas infoast_to_gtir.d[1],d[0][1],d[1].lb) were typed as the whole tuple, and nested ones were rejected. They are now typed as the element (literal integer index required) and lowered totuple_get.CollapseTuple.FLATTEN_AS_FIELDOP_ARGSnamed its let variables with a counter restarting per application, so flattening a nested tuple inside a surviving let captured the outer variable (d[2]becamed[1][2],IndexErroron gtfn). Names now come fromuids.