Skip to content

fix(ast-engine): harden Language::from_path default — better diagnostics and contract tests#102

Merged
bashandbone merged 3 commits intofix-language-from-path-12198073203083672702from
copilot/sub-pr-98
Mar 9, 2026
Merged

fix(ast-engine): harden Language::from_path default — better diagnostics and contract tests#102
bashandbone merged 3 commits intofix-language-from-path-12198073203083672702from
copilot/sub-pr-98

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

The previous unimplemented!("from_path is not implemented") message gave no indication of which type failed or how to fix it. The doc comment still described the old None-returning behavior.

Changes

  • Panic message: includes the concrete type name and remediation guidance via std::any::type_name::<Self>()
    unimplemented!(
        "Language::from_path is not implemented for type `{}`. \
         Override Language::from_path for this type if path-based detection is required.",
        std::any::type_name::<Self>()
    )
  • Doc comment: updated to reflect that the default panics; implementors must return Some(Self) / None
  • Tests: two new unit tests pin the contract
    • default_from_path_panics — asserts #[should_panic(expected = "Language::from_path is not implemented for type")] on a bare impl
    • overridden_from_path_does_not_panic — verifies an overriding impl returns Some/None correctly
  • Test fixtures: extracted shared TSX helpers (tsx_kind_to_id, tsx_field_to_id, tsx_ts_language) to remove duplication across test Language impls

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@bashandbone bashandbone marked this pull request as ready for review March 9, 2026 23:38
Copilot AI review requested due to automatic review settings March 9, 2026 23:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…add tests

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix panic if from_path is not implemented in ast-engine fix(ast-engine): harden Language::from_path default — better diagnostics and contract tests Mar 9, 2026
…ot/sub-pr-98

Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

👋 Hey @Copilot,

Thanks for your contribution to thread! 🧵

You need to agree to the CLA first... 🖊️

Before we can accept your contribution, you need to agree to our Contributor License Agreement (CLA).

To agree to the CLA, please comment:

I read the contributors license agreement and I agree to it.

Those exact words are important1, so please don't change them. 😉

You can read the full CLA here: Contributor License Agreement


✅ @Copilot has signed the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Footnotes

  1. Our bot needs those exact words to recognize that you agree to the CLA.

@bashandbone bashandbone merged commit 7bff512 into fix-language-from-path-12198073203083672702 Mar 9, 2026
2 of 3 checks passed
@bashandbone bashandbone deleted the copilot/sub-pr-98 branch March 9, 2026 23:42
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants