Replace regex-based interpolation with character scanner#4747
Draft
shreyas-goenka wants to merge 2 commits intomainfrom
Draft
Replace regex-based interpolation with character scanner#4747shreyas-goenka wants to merge 2 commits intomainfrom
shreyas-goenka wants to merge 2 commits intomainfrom
Conversation
- Move interpolation parser to libs/interpolation/ (independent of dyn)
- Use \$ -> $ and \\ -> \ escape sequences (Bash convention)
- Reject nested ${} constructs as errors
- Replace strings.Replace interpolation with token-based concatenation
- Add WarnMalformedReferences mutator for early parse error warnings
- Add NewRefWithDiagnostics for surfacing parse errors as diagnostics
Co-authored-by: Isaac
5 tasks
Collaborator
|
Commit: 523e287
16 interesting tests: 7 SKIP, 6 RECOVERED, 3 flaky
Top 20 slowest tests (at least 2 minutes):
|
The var_in_var test used ${var.foo_${var.tail}} which relied on
undocumented nested reference behavior (the test itself noted:
"not officially supported... might start to reject this in the future").
The new parser now rejects nested ${} constructs as intended.
Co-authored-by: Isaac
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.
Summary
Split from #4715. This PR replaces the regex-based variable reference parser with a two-mode character scanner, addressing review feedback:
libs/interpolation/(out oflibs/dyn/, per review)$$to\$→$and\\→\(Bash convention, per core eng discussion)${var.foo_${var.tail}}as error instead of silently handling (per review)strings.Replaceinterpolation with token-based concatenationWarnMalformedReferencesmutator for early parse error warningsNewRefWithDiagnosticsfor surfacing parse errors as diagnosticsvar_in_vartest which relied on undocumented nested ref behavior (test itself noted: "not officially supported, might reject in the future")Test plan
go test ./libs/interpolation/...— parser unit testsgo test ./libs/dyn/dynvar/...— ref, resolve testsgo test ./bundle/config/mutator/...— mutator testsgo test ./acceptance -run TestAccept/bundle/variables/malformed_referencego test ./acceptance -run TestAccept/bundle/resource_deps/bad_syntaxgo test ./acceptance -run TestAccept/bundle/variables/var_in_varmake fmtfull && make lintfullcleanThis pull request was AI-assisted by Isaac.