refactor(p4): evaluate IfExpr purely on the AST — remove P4IfSourceSupport char-scan shadow - #52
Merged
Merged
Conversation
…port shadow evalIfExpr used to re-parse the original formula's condition/then/else snippets (tryEvaluateIfFromSource -> P4IfSourceSupport, a char-scanning re-parse with findMatching/charAt) and only fall back to eval(node.condition())/eval(branch). That source shadow was a correctness crutch from when mapped IfExpr sub-trees were unfaithful. With the mapper fixes (#43/#32/#35/#49) and packrat memoization now default-on, the condition/branch nodes evaluate correctly on their own. - evalIfExpr is now pure-AST (eval condition, pick branch, eval branch). - Deleted the now-dead tryEvaluateIfFromSource and the P4IfSourceSupport class (the largest remaining char-scanning source-reparse shadow). Verified: full suite 633 tests, 0 failures/errors; baseline gate green (no new failures) with the shadow removed — i.e. the pure-AST if path is faithful. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
背景(charAt 撲滅 / fallback=0)
evalIfExprは元ソースの condition/then/else スニペットを文字走査で再パース(tryEvaluateIfFromSource→P4IfSourceSupport:findMatching/charAt)してから純 AST 評価にフォールバックしていました。これはマッパーが IfExpr 部分木を忠実に AST 化できなかった頃の正確性クラッチです。#43/#32/#35/#49 のマッパー修正+packrat memoize 既定 ON により、condition/branch ノードは単体で正しく評価できます。変更
evalIfExprを純 AST 評価化(condition 評価→枝選択→枝評価)。tryEvaluateIfFromSourceとP4IfSourceSupport(最大の残存 char-scan source-reparse shadow)を削除。検証
shadow を外した状態でフルスイート 633 tests, 0 failures/errors、baseline ゲート緑(新規失敗なし)=純 AST の if 経路が忠実であることを実証。
🤖 Generated with Claude Code