refactor(hm-dsl-engine): Replace positional (bool, bool) detection result with a named struct or DslLanguage set#114
Merged
markovejnovic merged 1 commit intoJun 10, 2026
Conversation
…sult with a named struct or DslLanguage set
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.
The smell
scan_extensionsincrates/hm-dsl-engine/src/detect.rsreturned a positional(bool, bool)meaning(has_py, has_ts). Three in-file consumers destructured it positionally:detect_languagematched(_, true)/(true, false)detect_language_python_firstmatched(true, _)/(false, true)has_pipeline_filesboundOk((py, ts))The two booleans are the same type, so swapping them (or transposing a match arm) is a silent logic bug the compiler cannot catch — a Python repo could resolve to TypeScript and still type-check.
The change
scan_extensionsnow returns a tiny named struct:All three call sites read
.has_py/.has_tsby name. The match-on-tuple sites becameif/else if/elsechains over the named fields. Logic, ordering (TS-preferred vs Python-preferred), error messages, and the public API (detect_language,detect_language_python_first,has_pipeline_files) are all unchanged. The new struct is private to the module.Type-safety pattern
This applies the "relational filter / result as a named type, not a loose bool pair" guidance from fd (
sharkdp/fd): naming the fields removes the positional-swap hazard while keeping behavior and the public surface identical. Ahas_py/has_tsmix-up is now impossible to express because the fields are addressed by name rather than position.Validation
Only
cargo check -p hm-dsl-enginewas run locally (passes clean). Full CI runs on this PR. Opened as draft for review.