Commit 221eca5
committed
Improve scope violation error messages to show inference chain
When a `@safe` function cannot call another function due to scope
violations during `@safe` inference, the error message now shows
WHY the callee's parameter could not be inferred as `scope`.
This is similar to how `@nogc` violations already show the full
inference chain, helping users understand the root cause of scope
errors without needing to manually trace through template instantiations.
Example output:
```
Error: `@safe` function `outer` cannot call `@system` function `inner`
and assigning scope variable `w` to non-scope parameter `w`
calling `callee` makes it fail to infer `@safe`
`w` is not `scope` because of `globalPtr = & w`
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>1 parent 47a8f81 commit 221eca5
File tree
6 files changed
+94
-8
lines changed- compiler
- src/dmd
- test/fail_compilation
6 files changed
+94
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
379 | | - | |
| 378 | + | |
| 379 | + | |
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| |||
2214 | 2214 | | |
2215 | 2215 | | |
2216 | 2216 | | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
2217 | 2225 | | |
2218 | 2226 | | |
2219 | 2227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3164 | 3164 | | |
3165 | 3165 | | |
3166 | 3166 | | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
3167 | 3173 | | |
3168 | 3174 | | |
3169 | 3175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3708 | 3708 | | |
3709 | 3709 | | |
3710 | 3710 | | |
| 3711 | + | |
3711 | 3712 | | |
3712 | 3713 | | |
3713 | 3714 | | |
3714 | | - | |
| 3715 | + | |
| 3716 | + | |
3715 | 3717 | | |
3716 | 3718 | | |
3717 | 3719 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1430 | 1430 | | |
1431 | 1431 | | |
1432 | 1432 | | |
| 1433 | + | |
| 1434 | + | |
1433 | 1435 | | |
1434 | 1436 | | |
1435 | 1437 | | |
| |||
1445 | 1447 | | |
1446 | 1448 | | |
1447 | 1449 | | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
1448 | 1456 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
373 | 380 | | |
374 | 381 | | |
375 | 382 | | |
376 | 383 | | |
377 | 384 | | |
378 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
379 | 389 | | |
380 | 390 | | |
381 | 391 | | |
| |||
460 | 470 | | |
461 | 471 | | |
462 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
463 | 480 | | |
464 | 481 | | |
465 | 482 | | |
| |||
504 | 521 | | |
505 | 522 | | |
506 | 523 | | |
507 | | - | |
| 524 | + | |
508 | 525 | | |
509 | 526 | | |
510 | 527 | | |
| |||
531 | 548 | | |
532 | 549 | | |
533 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
534 | 558 | | |
535 | 559 | | |
536 | 560 | | |
| |||
540 | 564 | | |
541 | 565 | | |
542 | 566 | | |
543 | | - | |
| 567 | + | |
544 | 568 | | |
545 | 569 | | |
546 | 570 | | |
| |||
556 | 580 | | |
557 | 581 | | |
558 | 582 | | |
559 | | - | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
560 | 587 | | |
561 | 588 | | |
562 | 589 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments