Skip to content

fix(semantic): no error in check_function_redeclaration for CommonJS files#18231

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/01-19-fix_semantic_no_error_in_check_function_redeclaration_for_commonjs_files
Jan 19, 2026
Merged

fix(semantic): no error in check_function_redeclaration for CommonJS files#18231
graphite-app[bot] merged 1 commit intomainfrom
om/01-19-fix_semantic_no_error_in_check_function_redeclaration_for_commonjs_files

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jan 19, 2026

I can't get my head around exactly what check_function_redeclaration is checking, so I'm not 100% sure about this change. But certainly this PR will make sure that behavior for CommonJS files is the same as it was before the introduction of commonjs source type.

Before commonjs source type existed:

  • Module: source_type.is_script() == false
  • Script: source_type.is_script() == true
  • CommonJS: source_type.is_script() == true

After introduction of commonjs source type:

  • Module: source_type.is_script() == false
  • Script: source_type.is_script() == true
  • CommonJS: source_type.is_script() == false (CHANGED)

After this PR:

  • Module: !source_type.is_module() == false
  • Script: !source_type.is_module() == true
  • CommonJS: !source_type.is_module() == true (CHANGED BACK)

@github-actions github-actions bot added A-semantic Area - Semantic C-bug Category - Bug labels Jan 19, 2026
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 19, 2026

Merging this PR will not alter performance

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/01-19-fix_semantic_no_error_in_check_function_redeclaration_for_commonjs_files (f5fb3a7) with main (ee9f6a4)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (f367769) during the generation of this report, so ee9f6a4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review January 19, 2026 12:54
Copilot AI review requested due to automatic review settings January 19, 2026 12:54
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 fixes a regression in check_function_redeclaration that was introduced when the commonjs source type was added. The change restores the previous behavior where CommonJS files are treated like scripts (not modules) for function redeclaration checking.

Changes:

  • Updated the condition in check_function_redeclaration from is_script() to !is_module() to correctly identify non-module files (Script, CommonJS, and Unambiguous)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
Copy link
Member

Dunqing commented Jan 19, 2026

Merge activity

graphite-app bot pushed a commit that referenced this pull request Jan 19, 2026
…S files (#18231)

I can't get my head around exactly what `check_function_redeclaration` is checking, so I'm not 100% sure about this change. But certainly this PR will make sure that behavior for CommonJS files is the same as it was before the introduction of `commonjs` source type.

Before `commonjs` source type existed:

* Module: `source_type.is_script() == false`
* Script: `source_type.is_script() == true`
* CommonJS: `source_type.is_script() == true`

After introduction of `commonjs` source type:

* Module: `source_type.is_script() == false`
* Script: `source_type.is_script() == true`
* CommonJS: `source_type.is_script() == false` **(CHANGED)**

After this PR:

* Module: `!source_type.is_module() == false`
* Script: `!source_type.is_module() == true`
* CommonJS: `!source_type.is_module() == true` **(CHANGED BACK)**
@graphite-app graphite-app bot force-pushed the om/01-19-fix_semantic_no_error_in_check_function_redeclaration_for_commonjs_files branch from f5fb3a7 to 4251813 Compare January 19, 2026 13:19
…S files (#18231)

I can't get my head around exactly what `check_function_redeclaration` is checking, so I'm not 100% sure about this change. But certainly this PR will make sure that behavior for CommonJS files is the same as it was before the introduction of `commonjs` source type.

Before `commonjs` source type existed:

* Module: `source_type.is_script() == false`
* Script: `source_type.is_script() == true`
* CommonJS: `source_type.is_script() == true`

After introduction of `commonjs` source type:

* Module: `source_type.is_script() == false`
* Script: `source_type.is_script() == true`
* CommonJS: `source_type.is_script() == false` **(CHANGED)**

After this PR:

* Module: `!source_type.is_module() == false`
* Script: `!source_type.is_module() == true`
* CommonJS: `!source_type.is_module() == true` **(CHANGED BACK)**
@graphite-app graphite-app bot force-pushed the om/01-19-fix_semantic_no_error_in_check_function_redeclaration_for_commonjs_files branch from 4251813 to f1e2dc0 Compare January 19, 2026 13:21
@graphite-app graphite-app bot merged commit f1e2dc0 into main Jan 19, 2026
21 checks passed
@graphite-app graphite-app bot deleted the om/01-19-fix_semantic_no_error_in_check_function_redeclaration_for_commonjs_files branch January 19, 2026 13:27
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
overlookmotel added a commit that referenced this pull request Jan 19, 2026
### 🐛 Bug Fixes

- f1e2dc0 semantic: No error in `check_function_redeclaration` for
CommonJS files (#18231) (overlookmotel)
- 645c3f0 transformer: Use `require` not `import` in CommonJS files
(#18226) (overlookmotel)
- ee9f6a4 mangler: Use `retain` instead of `truncate` to remove empty
frequency slots (#18225) (Dunqing)

### ⚡ Performance

- 52073d9 semantic: Use cheaper test for source type (#18235)
(overlookmotel)

Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>
graphite-app bot pushed a commit that referenced this pull request Jan 20, 2026
Follow-on after #18231. Add test cases to make sure function redeclaration check works correctly in script, module, and CommonJS files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants