Repository: deno
Issue: Error in deno while debugging code using vscode
Labels: bug,upstream,debugger,needs investigation

**Describe the bug**
Error in deno while debugging code using vscode
**Steps to Reproduce**
The debug code looks like this:
```ts
class Test {
    run() {
      const resources: any[] = [1, 2, 3];
  
      for (const adapter of resources) {
        Promise.resolve().then(() => {
          console.log(resources.at(adapter));
        });
      }
      console.log("end");
    }
  }
  new Test().run();
  
```
Set the breakpoint at the line 5

![image](https://github.com/user-attachments/assets/66ba2f7d-521b-47b5-a667-df9af585d5ac)
launch.json is configured as follows：
```json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Run TS",
      "request": "launch",
      "type": "node",
      "program": "${file}",
      "cwd": "${workspaceFolder}",
      "sourceMaps": true,
      "runtimeArgs": ["run"],
      "runtimeExecutable": "A:/repo/study/deno/deno.exe"
    }
  ]
}
```
Now start debugging through vscode ui.

The debug console outputs the following:
```
A:/repo/study/deno/deno.exe run --inspect-brk=127.0.0.1:53687 --allow-all .\a.ts
Debugger listening on ws://127.0.0.1:53687/ws/c5dc8fd1-a48e-48ca-8514-7452e087c0f7
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
Debugger session started.


#
# Fatal error in , line 0
# Check failed: needs_context && current_scope_ == closure_scope_ && current_scope_->is_function_scope() && !function_.is_null() implies function_->context() != *context_.
#
#
#
#FailureMessage Object: 000000403A7F4660
==== C stack trace ===============================

	CrashForExceptionInNonABICompliantCodeRange [0x00007FF770EDD34B+1316811]
	onig_get_string_end_by_callout_args [0x00007FF770BCA827+10150415]
	onig_get_string_end_by_callout_args [0x00007FF770C26597+10526591]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF77146F983+7159299]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF77146EB31+7155633]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF77129934B+5232587]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF770F5A570+1829360]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF770F4E5C5+1780293]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF770EE8999+1363481]
	onig_get_string_end_by_callout_args [0x00007FF770BCD804+10162668]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF770EE4536+1345974]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF770EE4914+1346964]
	onig_get_string_end_by_callout_args [0x00007FF770D8B93A+11989794]
	onig_get_string_end_by_callout_args [0x00007FF770D8AB6B+11986259]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF77117C5EA+4065898]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF771FF7C7F+19251455]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF7720DBD7E+20185598]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF771F566DE+18590558]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF771F566DE+18590558]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF771F9A6CD+18869069]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF771F5425C+18581212]
	CrashForExceptionInNonABICompliantCodeRange [0x00007FF771F53DAF+18580015]
	onig_get_string_end_by_callout_args [0x00007FF770D22578+11558752]
	onig_get_string_end_by_callout_args [0x00007FF770D23155+11561789]
	onig_get_string_end_by_callout_args [0x00007FF770D232B3+11562139]
	onig_get_string_end_by_callout_args [0x00007FF770D2A8D1+11592377]
	onig_get_string_end_by_callout_args [0x00007FF770D2A02A+11590162]
	onig_get_string_end_by_callout_args [0x00007FF770D29A9F+11588743]
	onig_get_string_end_by_callout_args [0x00007FF770D23CDC+11564740]
	onig_get_string_end_by_callout_args [0x00007FF770BAB95D+10023749]
	onig_get_string_end_by_callout_args [0x00007FF770B97A40+9942056]
	onig_get_start_by_callout_args [0x00007FF76F16216D+3445385]
	onig_get_capture_tree [0x00007FF76ED2D187+4610007]
	onig_get_capture_tree [0x00007FF76ED2A4B2+4598530]
	onig_get_capture_tree [0x00007FF76ED28CBE+4592398]
	onig_get_capture_tree [0x00007FF76ECC6459+4188841]
	onig_get_capture_tree [0x00007FF76ED3A3A2+4663794]
	onig_get_regex_by_callout_args [0x00007FF76E700BFF+265199]
	onig_get_capture_tree [0x00007FF76EE096E5+5512501]
	onig_get_regex_by_callout_args [0x00007FF76E85A844+1681460]
	onig_get_capture_tree [0x00007FF76ED5BDDB+4801579]
	onig_get_regex_by_callout_args [0x00007FF76E6CE9C6+59830]
	onig_get_capture_tree [0x00007FF76EE097C7+5512727]
	onig_unicode_define_user_property [0x00007FF7722775DC+1088992]
	BaseThreadInitThunk [0x00007FF92195257D+29]
	RtlUserThreadStart [0x00007FF922B2AF08+40]

```

If I set the breakpoint to line 7 or line 10, deno will be able to stop at the breakpoint

**Expected behavior**

The program stops at the breakpoint on line five

**Environment**

- OS: Windows 11 23H2
- deno version: 2.0.4