Commit fd547c3
rsscript: generic type aliases expand at every comparison site
Type aliases were only resolved for `let` bindings, and only by exact name — so a
non-generic alias used as a parameter type (`xs: read IntList`) and any generic
alias (`Pair<Int>`) failed type comparison (RS0207).
Add `Analyzer::expand_type_alias`: it expands an alias reference (generic or not)
by looking up the alias root and substituting the reference's arguments for the
alias's parameters (via text_util::substitute_type_args), chasing the chain with a
depth bound. Applied at the call-argument, return, and binding comparison sites;
generic aliases now resolve as param/return/binding types.
Test: tests/fixtures/pass/type-alias-generic.rss (Pair<T>=Result<T,String>,
IntList=List<Int> across all positions). lib/frontend/lowering green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent cc3634e commit fd547c3
4 files changed
Lines changed: 103 additions & 12 deletions
File tree
- crates/rsscript
- src
- checks
- tests/fixtures/pass
- docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
181 | 189 | | |
182 | 190 | | |
183 | 191 | | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
| 196 | + | |
188 | 197 | | |
189 | 198 | | |
190 | 199 | | |
| |||
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
210 | 241 | | |
211 | 242 | | |
212 | 243 | | |
| |||
219 | 250 | | |
220 | 251 | | |
221 | 252 | | |
| 253 | + | |
222 | 254 | | |
223 | 255 | | |
224 | 256 | | |
| |||
251 | 283 | | |
252 | 284 | | |
253 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
254 | 289 | | |
255 | 290 | | |
256 | 291 | | |
| |||
1039 | 1074 | | |
1040 | 1075 | | |
1041 | 1076 | | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1042 | 1111 | | |
1043 | 1112 | | |
1044 | 1113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
361 | | - | |
| 360 | + | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
726 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
727 | 730 | | |
728 | 731 | | |
729 | 732 | | |
| |||
1344 | 1347 | | |
1345 | 1348 | | |
1346 | 1349 | | |
1347 | | - | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
1348 | 1354 | | |
1349 | 1355 | | |
1350 | 1356 | | |
| |||
Lines changed: 21 additions & 0 deletions
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 16 | | |
22 | 17 | | |
23 | 18 | | |
| |||
0 commit comments