Skip to content

fix: incorrect inject field message for exact class extra field #3212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2025

Conversation

tomlau10
Copy link
Contributor

I found this display bug while discussing in an issue: #3211 (comment)

before

---@class (exact) A
---@field a integer
local A = {
    b = 1,  --> Fields cannot be injected into the reference of `A` for `A`.
}

=> the msg incorrectly uses class name `A` for `A`

after

---@class (exact) A
---@field a integer
local A = {
    b = 1,  --> Fields cannot be injected into the reference of `A` for `b`.
}

=> the correct msg should be using the field name `A` for `b`

@CppCXY CppCXY requested a review from Copilot June 27, 2025 07:51
Copy link

@Copilot 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.

Pull Request Overview

This PR corrects the diagnostic message for injecting an extra field into an exact-class table so that it references the field name rather than the class name.

  • Update the message payload in inject-field.lua to use the actual field identifier
  • Add a changelog entry under Unreleased to document the fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
script/core/diagnostics/inject-field.lua Use field instead of src when building the diagnostic message
changelog.md Add a FIX entry for the incorrect inject-field message
Comments suppressed due to low confidence (1)

script/core/diagnostics/inject-field.lua:137

  • Consider adding or updating a unit test for the exact-class extra-field diagnostic to verify that the message now correctly mentions the field name instead of the class name.
                field = guide.getKeyName(field),

@sumneko
Copy link
Collaborator

sumneko commented Jul 15, 2025

Thank you!

@sumneko sumneko merged commit cc9b302 into LuaLS:master Jul 15, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants