Skip to content
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

Shadowing error when field names matches package #86

Closed
dnaka91 opened this issue Sep 8, 2024 · 5 comments · Fixed by andrewhickman/prost-reflect#127
Closed

Shadowing error when field names matches package #86

dnaka91 opened this issue Sep 8, 2024 · 5 comments · Fixed by andrewhickman/prost-reflect#127

Comments

@dnaka91
Copy link

dnaka91 commented Sep 8, 2024

I encountered a false positive shadowing error when the field name of a message matches the package name of an imported message. This is accepted by protoc but protox detects it as a shadowing issue.

Minimal reproducible example

Having 2 Protobuf schemas with the following content:

In other.proto

syntax = "proto3";

package other;

message Other {}

In sample.proto

syntax = "proto3";

package sample;

import "other.proto";

message Sample {
  other.Other other = 1;
}

Error message

  Error:   × name 'other.Other' is shadowed
     ╭─[sample.proto:8:3]
   7 │ message Sample {
   8 │   other.Other other = 1;
     ·   ─────┬─────
     ·        ╰── found here
   9 │ }
     ╰────
    help: 'other.Other' is is resolved to 'sample.Sample.other.Other', which
          is not defined. The innermost scope is searched first in name
          resolution. Consider using a leading '.'(i.e., '.other.Other') to
          start from the outermost scope.

Current workaround

When renaming the field the issue can be worked around, but changing the field names is not really an option in my bigger setup, as they are already being used in several places.

@andrewhickman
Copy link
Owner

Thanks for the report, I expect that you can work around this by locking the version of prost-reflect to version 0.14.0 which didn't have andrewhickman/prost-reflect#126. I'll take a look at fixing this.

@andrewhickman
Copy link
Owner

This is also a re-occurrence of #57

@dnaka91
Copy link
Author

dnaka91 commented Sep 8, 2024

Thanks for taking a look so quickly. I'll pin it to that version for now as a temporary workaround 👍.

@andrewhickman
Copy link
Owner

@dnaka91 Hopefully this is fixed in prost-reflect 0.14.2

andrewhickman added a commit that referenced this issue Sep 9, 2024
andrewhickman added a commit that referenced this issue Sep 9, 2024
andrewhickman added a commit that referenced this issue Sep 9, 2024
@dnaka91
Copy link
Author

dnaka91 commented Sep 9, 2024

Works like a charm, thanks for the quick fix.

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 a pull request may close this issue.

2 participants