fix(ast): correct tree indentation, render use statements, print source-syntax operators - #15
Open
Boreas618 wants to merge 2 commits into
Open
fix(ast): correct tree indentation, render use statements, print source-syntax operators#15Boreas618 wants to merge 2 commits into
Boreas618 wants to merge 2 commits into
Conversation
Boreas618
commented
Aug 1, 2026
| /// | ||
| /// The LLVM IR mnemonics (`add`, `sdiv`, …) are printed by the IR layer's | ||
| /// own `ArithBinOp` Display impl in `ir::stmt`; all consumers of this impl | ||
| /// (the AST tree dump and `ir::Error` messages) are cosmetic. |
Contributor
Author
There was a problem hiding this comment.
comments should be clean-slate. don't need to specially mention "The LLVM IR mnemonics...", applicable also to another change.
| let mut new_indent = indent_levels.to_vec(); | ||
| new_indent.push(!is_last); | ||
| let last_index = self.elements.len().saturating_sub(1); | ||
| new_indent.push(is_last); |
Contributor
Author
There was a problem hiding this comment.
why !is_last to is_last?
…ce-syntax operators Fix three inverted tree-indent flags in the AST tree printer (Program, FnDecl, FnDef pushed !is_last into the child indentation context, contradicting the DisplayAsTree contract and the 19 other sites that push is_last). This broke vertical connector continuity in --emit ast dumps for nested subtrees; all three now push is_last. Render use statements in the AST dump. Program::fmt_tree previously iterated only elements and silently dropped use_stmts. A new leaf-style DisplayAsTree impl for UseStmt prints 'UseStmt <module_path>', and Program::fmt_tree now emits use_stmts before elements, marking only the final child overall as is_last. Remove the IR-vocabulary leak from AST Display: ArithBiOp and ComOp printed LLVM mnemonics (sdiv, sgt, ...) instead of TeaLang source syntax. All consumers of these impls are cosmetic -- the AST tree dump (IfStmt/WhileStmt/ReturnStmt condition headers) and ir::Error messages -- while IR emission uses the IR layer's own ArithBinOp/CmpPredicate Display impls in ir::stmt. They now print + - * / and == != > >= < <=.
- removed 10 narrations (§5.1): per-branch connector explainers in tree_indent, restatements of adjacent code or of the enclosing doc comment in Program::fmt_tree, VarDecl, FnDecl, VarDef, FnCall Display - rewrote 1 restatement into the last_index derivation in Program::fmt_tree (§2.2) - trimmed 1 filler clause from the tree.rs module doc (§8.2) - no divider banners, non-spec annotation tags, or commented-out code present in these files
Boreas618
force-pushed
the
fix/ast-tree-printer
branch
from
August 1, 2026 10:59
5f3464c to
116dddb
Compare
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.
AST-layer unification fixes from the cross-layer audit:
DisplayAsTreeimpls pushed!is_lastfor child indent levels while the trait's own contract (and the 19 other sites) pushis_last— vertical connectors broke underProgram/FnDecl/FnDef.usestatements were invisible:Program::fmt_treeonly iteratedelements;use_stmtsnow render first, with a newDisplayAsTree for UseStmt.ArithBiOp/ComOpDisplay printed LLVM mnemonics (sdiv/sgt); the AST now prints TeaLang source syntax. All consumers of these impls (tree dump, error messages) are cosmetic — IR printing uses its own op types.Verified:
cargo test30/30 green.