Skip to content

Conversation

@11happy
Copy link
Contributor

@11happy 11happy commented Nov 7, 2025

Summary

This PR implements is_bound_parameter for ty for syntax error name is parameter and global, this is a follow up to this #20426

Test Plan

mdtest and snapshots

CC

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

mypy_primer results

No ecosystem changes detected ✅

No memory usage changes detected ✅

Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Nov 7, 2025
@MichaReiser MichaReiser changed the title [ty]: name is parameter and global is a syntax error [ty] name is parameter and global is a syntax error Nov 9, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

It seems some mdtests are failing. Would you mind taking a look at why they're failing?

@11happy
Copy link
Contributor Author

11happy commented Nov 10, 2025

crates/ty_python_semantic/resources/mdtest/diagnostics/semantic_syntax_errors.md:386 unexpected error: 12 [unresolved-global] "Invalid global declaration of `a`: `a` has no declarations or bindings in the global scope"

crates/ty_python_semantic/resources/mdtest/diagnostics/semantic_syntax_errors.md:386 unexpected error: 12 [invalid-syntax] "name `a` is used prior to global declaration"

actually two more errors are also emitted along with the expected one , can we supress others ? as the changes in this PR are not related to other two errors ,

@ntBre
Copy link
Contributor

ntBre commented Nov 10, 2025

For the first error, I think you can just add a global a binding before the function definition. The second case looks interesting, I think it's basically a conflicting error with the error you're adding in this PR. I think we might want to suppress the used prior to global declaration error in this case so that we only report the more specific parameter and global error.

I checked how we handle this in ruff too, and it looks like we only emit the parameter and global syntax error, even if PLE0118 is also enabled.

@11happy
Copy link
Contributor Author

11happy commented Nov 12, 2025

For the first error, I think you can just add a global a binding before the function definition. The second case looks interesting, I think it's basically a conflicting error with the error you're adding in this PR. I think we might want to suppress the used prior to global declaration error in this case so that we only report the more specific parameter and global error.

I checked how we handle this in ruff too, and it looks like we only emit the parameter and global syntax error, even if PLE0118 is also enabled.

what do you think of this approach I have added a new symbol flag _IS_PARAMETER ? is working as expected now

Signed-off-by: 11happy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants