Commit dda0fe0
committed
inline: do not auto-inline a body that reads a parameter inside a
can_shadow block
A can_shadow block argument is one the shadowing check deliberately lets
cover an outer name of the same spelling. Hosts set it on generated query
blocks (dagor's ecs marks every [es] component argument), and
daslib/linq_boost sets it on the blocks it generates.
Splicing a callee that reads a parameter inside such a block is unsafe.
The parameter becomes the caller's argument expression, and when that
expression names a variable the block also declares, it rebinds to the
block's variable. Nothing reports it, because can_shadow is exactly what
switches error 30701 off, so the program is silently wrong rather than
rejected:
def callee(squad_team : int)
return apply_team() <| $ [shadowable] (team : int)
return squad_team * 100 + team
def caller(team : int)
return callee(team) // 505, should be 705
The 505 is the block's own team (5) used for both operands. In dagor's
enlisted this turned `squad_team != team` into `team != team`; that one
happened to trip -Wtautological-compare in the AOT output, but a
collision between two different variables compiles clean and just
computes the wrong value.
Keep those callees out of the heuristic tier. An explicit [inline] still
splices - that contract is the author's call. The added test fails with
505 before the change.1 parent 3f4e6d4 commit dda0fe0
3 files changed
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
568 | 594 | | |
569 | 595 | | |
570 | 596 | | |
| |||
582 | 608 | | |
583 | 609 | | |
584 | 610 | | |
| 611 | + | |
585 | 612 | | |
586 | 613 | | |
587 | 614 | | |
| |||
| 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 | + | |
| 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 | + | |
0 commit comments