Repository navigation
chore: ast to ast lowering - #70
Merged
Merged
Conversation
IzioDev
commented
Oct 14, 2026
Collaborator
- parse source once and resolve names across imports before building each app.
- lower authored code directly into sil contract syntax trees for formatting and compilation.
- separate app planning, model validation, contract generation, and artifact writing into clearer compiler stages.
- update compiler tests, generated sil fixtures, and architecture docs for the new pipeline.
Collaborator
Author
|
note @michaelsutton the artifact JSON fields didn't change, just are re-ordered and formatted differently (with serde json) |
Collaborator
|
see IzioDev#1 |
Keep authored identifier expressions and their source spans when materializing constructed successors instead of rebuilding spanless identifiers from their spelling. The final bound-name lowering pass can then resolve imported state constants correctly, including when another module declares a constant with the same name. Apply the fix to current emits and observed or spawned outputs. Generalize the materialization and output-validation helpers over expression lifetimes so source-backed references survive without introducing extra evaluation or changing compiler-owned route-field sources. Add regression coverage for all three output paths with both aligned and augmented physical state layouts. Each case includes a conflicting root constant and verifies that authored fields come from the imported state constant while generated fields come from the route context. Validation: Argent check.sh passes with 655 workspace tests, doctests, formatting, and warning-clean Clippy. Playground check.sh passes all transaction flows. All ten example artifacts regenerated under /tmp remain byte-for-byte identical to their pinned versions.
Resolve each named array dimension independently of its base type and retain the constant declaration identity by type site and dimension index. Dimension-only uses now participate in declaration dependency selection instead of being left as unresolved source spellings. Lower dimension references to their collision-safe Sil names in entry bodies, global helpers, actor helpers, typed array literals, and postfix casts. Retain parsed type metadata for postfix cast binding and reuse the existing type and name lowering boundaries without adding a source scanner or changing constant evaluation policy. Add resolver tests for dimension identities, dependency retention, unchanged authored types, and rejection of missing or nonconstant declarations. Add compilation coverage for two imports exporting LEN alongside a conflicting root LEN, including nested primitive arrays, authored state arrays, shared byte-array constants, and postfix casts. Keep direct byte[CONST](buffer) casts outside the supported boundary, as on master. Validation: Argent check.sh passes with 658 workspace tests, doctests, formatting, and warning-clean Clippy. Playground check.sh passes all transaction flows. Differential reproducers produce artifacts identical to master, and all ten regenerated example artifacts match their pinned versions.
Recognize a hex byte-sequence initializer through redundant parentheses and an optional trailing comma on the outer cast argument. Keep the existing byte decoding and length validation instead of falling back to integer parsing, which rejected long hex literals or compiled shorter ones as unsupported integer-to-array casts. Look ahead without consuming tokens until the complete single-literal shape matches. Expressions, extra arguments, and malformed parenthesis shapes continue through ordinary expression parsing rather than being mistaken for a byte literal. Compare parsed AST shapes against the pinned Sil compiler for byte arrays, pubkey, sig, and datasig across plain and nested parentheses with and without trailing commas. Cover empty hex arrays, retained size errors, arithmetic arguments, and multi-argument calls. Validation: Argent check.sh passes with 659 workspace tests, doctests, formatting, and warning-clean Clippy. Playground check.sh passes all transaction flows. Six end-to-end regression probes produce artifacts identical to master, and all ten regenerated example artifacts match their pinned versions.
Use the canonical source file parent when loading relative filesystem imports. Keep the originally requested absolute path for diagnostics and source display, but do not let a symlink location change which dependencies belong to an otherwise identical module. This restores master behavior and makes import resolution consistent with the existing canonical-path source identity and deduplication. Loading a module through its real path or a symlink must not select different sibling files depending on which path is discovered first. Add a Unix symlink regression test with both a missing and a conflicting dependency beside the link. Exercise both initial load orders, verify the real dependency is selected, preserve the requested diagnostic path, and ensure the direct path and symlink retain one module identity. Validation: Argent check.sh passes with 660 workspace tests, doctests, formatting, and warning-clean Clippy. Playground check.sh passes all transaction flows. The original symlink reproducer builds with the same artifact ID and Sil ABI as master while retaining its requested display path. All ten regenerated example artifacts match their pinned versions.
Include readInputStateWithTemplate and all three output-state validation builtins in source reference resolution. The AST lowering refactor accidentally rejected these previously supported calls as unknown references. Keep builtin recognition restricted to call and type sites so bare identifiers cannot capture actor fields. Add resolver coverage for each restored name and compile authenticated state reads, typed destructuring, and output validations through both the retained AST and formatted Sil. Validation: ./check.sh passes with 662 tests, doctests, formatting, and warning-clean Clippy.
Use each indexed reference role when binding authored names. Resolve calls against actor helpers, source declarations, or builtins without allowing a same-named parameter, local, or actor field to capture the call target. Resolve constructor types independently of lexical value bindings. Keep actor helper identities in the callable table instead of seeding them into value scopes. This also preserves actor-field identity when a helper shares its name, including covenant-id fields used by co_spent. Global helper hygiene now renames only the value binding while leaving the selected function or constructor intact. Add resolver tests for function, builtin, actor-helper, and constructor bindings, and reject missing functions or types even when a local has the same name. Compile parameter and local collisions in entries and both helper kinds, statement and result-binding calls, builtin constructors, and shared actor-field/helper names. Verify formatted Sil compiles to the same bytecode as the retained AST. Validation: Argent ./check.sh passes with 669 tests, doctests, formatting, and warning-clean Clippy. Playground ./check.sh passes all transaction flows. All 15 differential reproducers match master artifacts, and all 11 pinned example artifacts regenerate unchanged under /tmp.
A local actor-enum selector initialized from an enum variant could retain a fixed actor and ordinal after assignments changed its value. Route lowering then used the initializer rather than the current local, allowing a successor template that contradicted the authored branch. Collect assigned LocalIds from resolved assignment-target sites and discard initializer-derived fixed metadata for those enum locals before selector construction. Route expansion, witness planning, artifact metadata, and code generation consequently retain the full enum domain and use the current value. Unwritten enum locals and symbolic actor_type handles retain their existing fixed-selector behavior. Add model coverage for direct, conditional, block, loop, and unreachable assignments, including unrelated same-named bindings in other entries and actor helpers. Execute both conditional routes with explicit ABI template witnesses, accepting the selected actor and rejecting the other. Also verify that unwritten locals retain automatic builder witness selection. Validation: Argent check.sh passes with 671 tests, doctests, formatting, and warning-clean Clippy. Playground check.sh passes all transaction flows. Regenerating existing examples in a temporary directory leaves every pinned Sil, manifest, and artifact byte-identical. Automatic builder inference of dynamic body-local selectors remains outside this fix.
Turn manual AST-lowering compatibility probes into a maintained test corpus using the Sil version pinned by Cargo. The oracle does not require a saved master binary, another checkout, or a particular Git branch. Compare parsed expressions in constants, entries, global helpers, and actor helpers with upstream Sil ASTs. Compare ordinary statements in all three body contexts, projecting only Argent control-flow wrappers. Ignore source-offset metadata while checking AST structure, name roles, authored expression and statement text, and name-span text. Account explicitly for the parsers differing in whether block spans include braces. Cover precedence, adjacent operators, parentheses, numeric and temporal literals, escaped and Unicode strings, hex casts, array dimensions, structs, destructuring, branches, loops, introspection, native calls, and shared malformed syntax. Add 34 end-to-end cases, each compiled in entry, global-helper, and actor-helper contexts against independently authored upstream Sil equivalents. Compare complete contract ABI records, including bytecode, dispatch tags, runtime state, and template metadata, plus struct records. Execute correct result claims and reject incorrect claims during script execution, including alternate branches and zero/nonzero loop iterations. Exercise callable and constructor names independently of local values, void helper calls, and covenant co-spend lowering. Check shared semantic errors and intentional Argent restrictions separately. Use explicit reference text for Argent-only syntax and auto-cleaned temporary build directories, including failure paths. Document how to run and extend the corpus and its limits. Leave production parsing and reservation fixes to the parallel work. No tests are ignored or allowlisted: the current workspace run has 716 of 719 tests passing, with three failures exposing the two known pending changes: compact negative-comparison parsing and reserving co_spent function names. Formatting, doctests, and warning-clean Clippy pass. Production logic and generated artifacts are unchanged.
Update only the kaspa-hashes version and checksum in Cargo.lock. The patch restores the omitted MSVC assembly source without changing existing hashing sources or the build script. All other dependencies remain unchanged. Clarify that the lexer leaves left-arrow symbols separate to preserve compact negative comparisons, while route parsing requires adjacency. Validation: archive checksum and MSVC assembly inclusion verified; 719 tests, doctests, formatting, and Clippy pass on Linux.
michaelsutton
approved these changes
Oct 23, 2026
RossKU
added a commit
to RossKU/argent
that referenced
this pull request
Oct 26, 2026
A module import of a published app artifact names the artifact id the
importer reviewed:
import "./asset/artifact.json" id "<artifact id>";
The loader reads the artifact, runs its consistency check and requires the
pinned id (an import without the pin, an `id` on a source or standard
module import, and an artifact as the root file are rejected). The
artifact is then described as declaration-only Argent source (its states,
actor enums, exported actors without entries and its app) that goes through
the same lexer, parser and name resolution as every other module, so
references into it resolve like references into a source import. The app
graph builder links the artifact as published, writes it below
apps/<App>/ and never compiles it; its declaration identities match what
a source import of the same app would report, so a bundle built against
the artifact equals one built against the source.
Ports the artifact import onto the AST-to-AST compiler (argent-lang#70).
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.