checker: allow byte as a parameter name - #28835
medvednikov wants to merge 2 commits into
Conversation
Include ordinary .param name offsets in the deprecated-byte identifier exemption map. Keep synthetic receiver positions excluded, and match only the exact name offset so a deprecated byte type remains diagnosed. This commits the compiler fix accompanying byte_parameter_name_test.v.
medvednikov
left a comment
There was a problem hiding this comment.
Reviewed at 1b00e731603f415c1d81e312fcaa00543e4989b9.
No actionable correctness issue found in the two-file diff. The new exemption is keyed by the parameter-name token's exact file ID and offset, rather than the parameter's entire source span. That is the important boundary for allowing a value named byte without exempting a separate deprecated type token. Synthetic receiver nodes remain excluded, and the raw-source scanner's other checks are unchanged.
The positive regression covers ordinary, later, grouped, mutable, and function-literal parameters with observable results. A useful non-blocking addition would be committed negative fixtures for fn f(byte byte) and fn f(byte []byte), asserting that the type occurrence still produces the deprecation diagnostic. Those cases are mentioned in the description but are not exercised by the new test file.
Validation: complete diff and surrounding deprecation-scanner source review. I did not run a compiler rebuild, formatter, or V tests because no V compiler is available locally. CI status and results were not considered.
Summary
This PR now includes the compiler fix, committed in
1b00e731603f415c1d81e312fcaa00543e4989b9, as well as the regression tests. It is no longer a tests-only PR.Fix the false
byte is deprecated, use u8 insteaddiagnostic for a parameter namedbytewith a non-deprecated type:Compiler change
In
vlib/v/types/checker.v,TypeChecker.check_deprecated_byte_types()now includes ordinary.paramname positions in its identifier-offset exemption map, alongside.identpositions.Only exact parameter-name offsets are exempted, not whole declaration spans. Consequently, the type token in
fn f(byte byte)and the element type infn f(byte []byte)are not exempted by this change. Synthetic receiver nodes (op == .dot) remain excluded because their positions do not identify the receiver name.The compiler diff is limited to three added lines and one removed line. No parser rules, diagnostic text, public APIs, or existing diagnostic expectations are changed.
Regression coverage
vlib/v/tests/byte_parameter_name_test.vcovers the reported signature, a later parameter namedbyte, grouped parameters withbytein either position, a mutable array parameter, and a function-literal parameter.Validation
Suggested validation from the repository root:
./v self ./v fmt -w vlib/v/types/checker.v vlib/v/tests/byte_parameter_name_test.v ./v vlib/v/tests/byte_parameter_name_test.v ./v -silent vlib/v/compiler_errors_test.v ./v test vlib/v/types/ ./v vlib/v/slow_tests/inout/compiler_test.vRun the new test with the default compiler itself; a successful old-compiler fallback does not validate this checker fix. Verify the existing
use_byte_instead_of_u8*diagnostics and the negative casesfn f(byte byte)/fn f(byte []byte)before marking ready.