Skip to content

Conversation

@jakebailey
Copy link
Member

Noticed these while trying gosec. Most of these are enum types that are paired up with another but underlying types differed, which is weird.

regexp2's constants are broken; they mistakenly forgot that only iota keeps inferring the same type as the first "enum" value in a block.

Copilot AI review requested due to automatic review settings October 29, 2025 05:41
Copy link
Contributor

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 updates type definitions for several flag enums from signed to unsigned integers for better semantic correctness, and refactors regex pattern compilation in VFS utilities.

  • Changes flag types from int32 to uint32 where values represent bitfields
  • Changes JSDocParsingMode from int to uint8 for a small enum with 4 values
  • Refactors GetRegexFromPattern to declare options variable upfront and build it conditionally
  • Updates fuzz tests to use correct primitive types (int32 and uint8) matching the underlying enum types
  • Updates module resolver test to use proper core.ModuleKind type instead of int

Reviewed Changes

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

Show a summary per file
File Description
internal/vfs/utilities.go Refactored regex options initialization to declare variable first, then conditionally modify it
internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe Updated fuzz test corpus to use int32 and uint8 types
internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a Updated fuzz test corpus to use int32 and uint8 types
internal/parser/parser_test.go Updated fuzz test to use int32 for ScriptTarget and uint8 for JSDocParsingMode
internal/nodebuilder/types.go Changed Flags type from int32 to uint32 for bitfield operations
internal/module/resolver_test.go Changed ResolutionMode from int to core.ModuleKind and removed unnecessary type casts
internal/checker/types.go Changed SymbolFormatFlags from int32 to uint32 for bitfield operations
internal/ast/subtreefacts.go Changed SubtreeFacts from int32 to uint32 for bitfield operations
internal/ast/parseoptions.go Changed JSDocParsingMode from int to uint8 for small enum
Comments suppressed due to low confidence (1)

internal/parser/parser_test.go:130

  • The upper bound check is incorrect. JSDocParsingModeParseNone has value 1 (second in iota sequence), but the last value is JSDocParsingModeParseForTypeInfo which has value 3. The condition should be jsdocParsingMode > ast.JSDocParsingModeParseForTypeInfo to correctly validate the full range of valid enum values (0-3).
		if jsdocParsingMode < ast.JSDocParsingModeParseAll || jsdocParsingMode > ast.JSDocParsingModeParseNone {

@jakebailey jakebailey added this pull request to the merge queue Oct 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 29, 2025
@jakebailey jakebailey added this pull request to the merge queue Oct 29, 2025
@jakebailey jakebailey removed this pull request from the merge queue due to a manual request Oct 29, 2025
@jakebailey jakebailey added this pull request to the merge queue Oct 29, 2025
@jakebailey jakebailey removed this pull request from the merge queue due to a manual request Oct 29, 2025
@jakebailey jakebailey added this pull request to the merge queue Oct 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 29, 2025
@jakebailey jakebailey added this pull request to the merge queue Oct 29, 2025
Merged via the queue into main with commit b278afd Oct 29, 2025
28 checks passed
@jakebailey jakebailey deleted the jabaile/fix-types branch October 29, 2025 22:29
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.

3 participants