schema: handle typedefs without a parsed signature - #40
Merged
Merged
Conversation
The tree-sitter parser emits parsedSignature: null for typedefs and typeset members that aren't function signatures, such as `typedef Address = int`, matching Option<TypeSignature> in libschema. The TS schema typed it as always present, so searching a bundle with one threw on `.arguments`. Type parsedSignature as nullable and index only the name when it's null. Bumps the schema to 0.1.19. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLCPZBzDzF1cP5qKEEhEsg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Searching a bundle from the new tree-sitter parser (#30) crashes the frontend:
The parser sets
parsedSignature: nullwhen a typedef or typeset member isn't a function signature, for exampletypedef Address = int. That matchesOption<TypeSignature>inlibschema. The TS schema typed the field as always present. The search code before #32 made the same assumption, so it would also have rejected on these bundles. Bundles from the previous parser never containnull, which is why this went unnoticed.Fix
parsedSignatureis nowITypeSignature | nullonITypeDefinition,ITypeand theTypeDefinitionclass.null, and skips typeset members whose signature isnull.@sourcemod-dev/schemais bumped to 0.1.19 so the fix can be published.Verification
search_index.test.tsnow includes a typedef and a typeset member withparsedSignature: null. With the fix reverted, the test fails with the sameTypeError. With the fix, all 8 tests pass.tsc --noEmitpasses.bundlesbranch ofsourcemod-dev/manifest: zero differences.🤖 Generated with Claude Code
https://claude.ai/code/session_01NLCPZBzDzF1cP5qKEEhEsg
Generated by Claude Code