# biome nursery/useUnicodeRegex: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: biome 2.5.15
- Rule: nursery/useUnicodeRegex (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): intended-change, severity low. The rule adds the 'u' flag to regexes lacking Unicode mode. The program constructs a new RegExp from an existing one and passes an additional 'i' flag; per the spec, the new RegExp inherits the source regex's flags unless overridden, so adding 'u' to the source makes the copy's flags become 'iu' instead of 'i'. This is the documented semantic change the rule exists to make.
- Program: minimized from 3 to 3 lines

## Reproducer

```js
let base = /a/g;
let copy = new RegExp(base, 'i');
console.log(copy.flags);
```

## Commands

```sh
node prog.js
bunx @biomejs/biome lint --only=nursery/useUnicodeRegex --write prog.js
node prog.js
```

## Observed

```
stdout before:
i
stdout after:
iu
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:32:57.180511834 -0400
+++ fixed.js	2026-10-22 13:32:59.349548314 -0400
@@ -1,3 +1,3 @@
-let base = /a/g;
-let copy = new RegExp(base, 'i');
+let base = /a/gu;
+let copy = new RegExp(base, 'iu');
 console.log(copy.flags);
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original regex `/a/g` has only the global flag; adding `u` via the fix changes its behavior to Unicode mode, which alters how patterns like `\w` or case-insensitive matching are interpreted—even if unused here. The copy inherits both `i` and `u` flags, so its `.flags` becomes `iu` instead of `i`. Though the current pattern `/a/` is unaffected by Unicode mode, the fix assumes safety without verifying that added flags don’t alter semantics for potential future patterns, making it unsafe in general. The observed change in output confirms the behavioral shift.

## Upstream search

Queries: "useUnicodeRegex fix", "nursery useUnicodeRegex regex constructor flags", "RegExp constructor unicode flag propagation", "useUnicodeRegex rule RegExp flags behavior"

- related: https://github.com/biomejs/biome/issues/11933
  same rule but different construct (invalid patterns in unicode mode vs RegExp constructor flag handling)
- related: https://github.com/biomejs/biome/issues/5693
  same domain (regex autofix) but different construct (useRegexLiterals escaping vs useUnicodeRegex flag handling)

<details><summary>All hits</summary>

- [github, open] 💅 `useUnicodeRegex` safe fix adds `u` to patterns that are invalid in unicode mode — https://github.com/biomejs/biome/issues/11933
- [github, closed] 💅 `useMathMinMax` false positive with Date values — https://github.com/biomejs/biome/issues/10272
- [github, closed] 💅 `nusery/noShadow` should not flag parameter names of function types — https://github.com/biomejs/biome/issues/9482
- [tavily] fix(css_parser): fix is at unicode range check by xin2017338 · Pull Request #3745 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/3745
- [tavily] 🐛 useRegexLiterals incorrect autofix · Issue #5693 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5693
- [tavily] fix(formatter): add break to ts constructor parameters with modifiers by TaKO8Ki · Pull Request #994 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/994
- [tavily] 🐛 Private class members used from constructor are incorrectly marked as unused · Issue #8138 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8138
- [tavily] feat(noImpliedEval): flag `new Function(...)` by dyc3 · Pull Request #9811 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9811
- [tavily] 📎 Port `prefer-regexp-test` · Issue #9377 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9377

</details>
