Skip to content

checker: allow byte as a parameter name - #28835

Draft
medvednikov wants to merge 2 commits into
masterfrom
fix/byte-parameter-deprecation
Draft

medvednikov wants to merge 2 commits into
masterfrom
fix/byte-parameter-deprecation

Conversation

@medvednikov

@medvednikov medvednikov commented Sep 21, 2026

Copy link
Copy Markdown
Member

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 instead diagnostic for a parameter named byte with a non-deprecated type:

fn utf8_second_context(byte u8) int {
	return int(byte)
}

Compiler change

In vlib/v/types/checker.v, TypeChecker.check_deprecated_byte_types() now includes ordinary .param name positions in its identifier-offset exemption map, alongside .ident positions.

Only exact parameter-name offsets are exempted, not whole declaration spans. Consequently, the type token in fn f(byte byte) and the element type in fn 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.v covers the reported signature, a later parameter named byte, grouped parameters with byte in either position, a mutable array parameter, and a function-literal parameter.

Validation

  • Read back the published PR patch and verified that it contains exactly the checker fix and the 47-line regression test file.
  • Verified the assembled full-source tree differs from the preceding PR commit only by the intended 3-line/1-line checker edit. The remainder of the checker and repository tree is preserved.
  • The compiler fix is a normal single-parent commit on the existing PR branch; temporary patch-assembly history is not part of this PR.
  • V compilation, tests, and formatting have not been run. The execution environment has no V compiler and cannot resolve GitHub for cloning/bootstrap. This remains a draft pending actual compiler validation; no successful runtime test result is claimed.

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.v

Run 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 cases fn f(byte byte) / fn f(byte []byte) before marking ready.

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 medvednikov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

This branch has not been deployed

No deployments
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.

1 participant