A type argument list is split on commas without tracking nesting, so an adaptor cannot be chained
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 61
Description
Chaining two generic structs fails in codegen:
import core::iter;
fn main() -> i32 {
let evens = filter(range(0i64, 10i64), | x : i64 | x % 2i64 == 0i64);
let mut scaled = map(evens, | x : i64 | x + 100i64);
for v in scaled {
print(v);
}
return 0;
}
struct without a body only allowed in a recursive struct
Codegen Error: failed to parse lowered MLIR type `!llvm.struct<"Filter<Range">`
The name arrives already cut at the comma. Map<Filter<Range, i64>, i64, i64> has a type argument that itself carries a comma, and the argument list is taken apart with a plain split(','), so Filter<Range and i64> become two arguments.
The sites that do this:
src/syntax/expr.rs:1042,:1144,:1250-- each splits aty_args_stron commassrc/codegen/lower/stmt.rs:520-- same shape
A depth-aware split, counting < and > and only breaking at depth 0, is what these want. One helper used at each site should do it.
Single-level adaptors are unaffected and work today: map, filter, take and skip over a Range each run correctly, as does a for loop over any of them. It is only a nested one that breaks, which is exactly the chaining an iterator library exists for.
Filed while writing core::iter, which ships with single-level adaptors only because of this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the comma-splitting sites in src/syntax/expr.rs:1042, :1144, :1250 and src/codegen/lower/stmt.rs:520, then trace how ty_args_str is parsed. The shared helper should split only at nesting depth zero. Done means the shown nested map/filter example compiles and runs, while the listed single-level adaptors remain working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100