Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

The identifier usage analyzer only counted identifiers in expanded code, missing macros that expand away completely. For example:

(define-syntax (m stx) #'(void))
(m)  ; Usage of m not counted

Changes

  • Extract identifiers from origin properties: Added origin-property-identifiers to recursively extract identifiers from the 'origin syntax property, which records disappeared macro uses. Handles property structures (single syntax, lists, nested pairs).

  • Visit all syntax objects: Modified usage-site-identifiers to use syntax-search-everything to check origin properties on all nodes during traversal.

  • Phase labeling: Applied phase labels to origin-extracted identifiers for correct binding matching across phases.

Performance Impact

Large macro expansions may exceed the 100ms analyzer timeout (2 test failures in for-loop-shortcuts-test.rkt). Trade-off prioritizes correctness; optimization possible via lazy stream operations.

Original prompt

This section details on the original issue you should resolve

<issue_title>Identifier usage analyzer should count expanded uses</issue_title>
<issue_description>This test of identifier-usage-analyzer currently fails:

#lang resyntax/test
header: - #lang racket/base

analysis-test: "disappeared use of macro"
--------------------
(require (for-syntax racket/base))
(define-syntax (m stx)
  #'(void))
(m)
--------------------
@within - (m stx)
@inspect - m
@property usage-count
@assert 1

That's because the (m) expression gets expanded away, and identifier-usage-analyzer only looks at the expanded code. Luckily, the expander records the fact that (m) was used during expansion by recording it in the 'origin syntax property. The identifier usage analyzer should look through these properties for usages and count them too.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix identifier usage analyzer to count expanded uses Count disappeared macro uses via origin property Nov 11, 2025
Copilot AI requested a review from jackfirth November 11, 2025 17:58
@jackfirth jackfirth marked this pull request as ready for review November 11, 2025 18:34
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 2 files in this pull request and found no issues.

@coveralls
Copy link

coveralls commented Nov 11, 2025

Coverage Status

coverage: 93.661% (+0.03%) from 93.63%
when pulling 5990d4c on copilot/fix-identifier-usage-analyzer
into 1c757cf on master.

Copilot AI and others added 3 commits November 11, 2025 18:24
Co-authored-by: jackfirth <8175575+jackfirth@users.noreply.github.com>
Co-authored-by: jackfirth <8175575+jackfirth@users.noreply.github.com>
@jackfirth jackfirth force-pushed the copilot/fix-identifier-usage-analyzer branch from dbcd02b to 5990d4c Compare November 12, 2025 02:24
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 2 files in this pull request and found no issues.

@jackfirth jackfirth merged commit ef1a5e9 into master Nov 12, 2025
7 checks passed
@jackfirth jackfirth deleted the copilot/fix-identifier-usage-analyzer branch November 12, 2025 02:55
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.

Identifier usage analyzer should count expanded uses

3 participants