Repository navigation
Commit b974adf
committed
fix: grow the ts_lsp AST walk stacks so wide files keep every declaration
Three walks in internal/cbm/lsp/ts_lsp.c held at most 256 AST nodes in a
fixed array and stopped pushing when it filled. Nothing reported the stop,
so the passes answered as if they had seen the whole file.
In rebuild_signatures_from_ast and convert_signature_type_params the
seeding loop alone can fill all 256 slots, because it pushes every
top-level child of the file. A file with more than 256 top-level
declarations therefore skipped every declaration past that point: each one
kept whatever signature the first extraction pass had guessed, and a
generic function past the cap kept NAMED instead of TYPE_PARAM, so calls
through it stopped resolving. In infer_return_type_from_body the same cap
made a wide function body answer "unknown return type" for a return the
walk had never reached.
The repo already carries the module that solves this:
internal/cbm/extract_node_stack.h, written for GitHub issue DeusData#199 to
replace fixed TSNode stack[] arrays that silently drop subtrees. Nine
extract files use it; ts_lsp.c was never converted. This converts it.
The header gains ts_nstack_init_arena, which takes an arena directly,
because the LSP passes hold a TSLSPContext rather than a CBMExtractCtx.
ts_nstack_init keeps its context argument, which is what makes handing
over the wrong arena a type error, and now delegates to the new function.
Traversal order changes from last-child-first to first-child-first,
because ts_nstack_push_children reverses on push. That also drops an
O(N^2) ts_node_child(n, i) loop for one cursor pass. For
infer_return_type_from_body the new order matches the comment the
function already carried: it finds the first return, where the old code
found the last.
New test tslsp_stress_declarations_past_stack_cap makes the same claim as
tslsp_generic_identity_inference, 300 declarations deeper in the file.
Without this change it fails with "MISSING resolved call: caller~.go ->
callee~use"; with it the ts_lsp suite is 304 passed, 0 failed.
Signed-off-by: Joshua Richter <jrichter5781@gmail.com>1 parent aa44c28 commit b974adf
3 files changed
Lines changed: 79 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
43 | 55 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
4634 | 4635 | | |
4635 | 4636 | | |
4636 | 4637 | | |
4637 | | - | |
4638 | | - | |
4639 | | - | |
4640 | | - | |
4641 | | - | |
4642 | | - | |
4643 | | - | |
| 4638 | + | |
| 4639 | + | |
| 4640 | + | |
| 4641 | + | |
| 4642 | + | |
| 4643 | + | |
| 4644 | + | |
| 4645 | + | |
| 4646 | + | |
4644 | 4647 | | |
4645 | 4648 | | |
4646 | 4649 | | |
| |||
4662 | 4665 | | |
4663 | 4666 | | |
4664 | 4667 | | |
4665 | | - | |
4666 | | - | |
4667 | | - | |
4668 | | - | |
| 4668 | + | |
4669 | 4669 | | |
4670 | 4670 | | |
4671 | 4671 | | |
| |||
4681 | 4681 | | |
4682 | 4682 | | |
4683 | 4683 | | |
4684 | | - | |
4685 | | - | |
4686 | | - | |
4687 | | - | |
4688 | | - | |
4689 | | - | |
| 4684 | + | |
| 4685 | + | |
| 4686 | + | |
| 4687 | + | |
| 4688 | + | |
| 4689 | + | |
| 4690 | + | |
4690 | 4691 | | |
4691 | | - | |
4692 | | - | |
| 4692 | + | |
| 4693 | + | |
4693 | 4694 | | |
4694 | 4695 | | |
4695 | 4696 | | |
4696 | 4697 | | |
4697 | 4698 | | |
4698 | 4699 | | |
4699 | | - | |
4700 | | - | |
4701 | | - | |
4702 | | - | |
| 4700 | + | |
4703 | 4701 | | |
4704 | 4702 | | |
4705 | 4703 | | |
4706 | 4704 | | |
4707 | | - | |
4708 | | - | |
| 4705 | + | |
| 4706 | + | |
4709 | 4707 | | |
4710 | 4708 | | |
4711 | 4709 | | |
| |||
4845 | 4843 | | |
4846 | 4844 | | |
4847 | 4845 | | |
4848 | | - | |
4849 | | - | |
4850 | | - | |
4851 | | - | |
4852 | | - | |
4853 | | - | |
4854 | | - | |
4855 | | - | |
4856 | | - | |
| 4846 | + | |
| 4847 | + | |
| 4848 | + | |
| 4849 | + | |
| 4850 | + | |
| 4851 | + | |
| 4852 | + | |
| 4853 | + | |
| 4854 | + | |
| 4855 | + | |
4857 | 4856 | | |
4858 | 4857 | | |
4859 | 4858 | | |
4860 | 4859 | | |
4861 | 4860 | | |
4862 | 4861 | | |
4863 | | - | |
4864 | | - | |
4865 | | - | |
4866 | | - | |
| 4862 | + | |
4867 | 4863 | | |
4868 | 4864 | | |
4869 | 4865 | | |
4870 | 4866 | | |
4871 | | - | |
4872 | | - | |
| 4867 | + | |
| 4868 | + | |
4873 | 4869 | | |
4874 | 4870 | | |
4875 | 4871 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2817 | 2817 | | |
2818 | 2818 | | |
2819 | 2819 | | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
2820 | 2849 | | |
2821 | 2850 | | |
2822 | 2851 | | |
| |||
4565 | 4594 | | |
4566 | 4595 | | |
4567 | 4596 | | |
| 4597 | + | |
4568 | 4598 | | |
4569 | 4599 | | |
4570 | 4600 | | |
| |||
0 commit comments