mismatched types
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 50/100
Research direction
Run the supplied test.rs reproducer first and confirm the recursive ADT mismatched-type errors. Then trace the compiler's recursive ADT and type-checking handling to determine why references are treated as mismatched types; done means the reproducer compiles without these errors.
Written by the indexing model from the issue text.
Description
#![feature(no_core, lang_items)]
#![no_core]
#[lang = "sized"]
pub trait Sized {}
extern "C" {
fn printf(format: *const i8, ...);
}
enum ast<'a> {
num(usize),
add(&'a ast<'a>, &'a ast<'a>),
}
fn eval(node: &ast) -> usize {
match node {
ast::num(n) => *n,
ast::add(l, r) => eval(l) + eval(r),
}
}
fn main() -> i32 {
let a = ast::num(3);
let b = ast::num(4);
let c = ast::add(&a, &b);
let d = ast::num(10);
let e = ast::add(&c, &d);
unsafe {
printf("%d\n\0" as *const str as *const i8, eval(&e) as i32);
}
0
}
with my recusive adts work this fails with:
test.rs:31:5: error: mismatched types, expected ‘& ast’ but got ‘ast’ [E0308]
31 | match node {
| ^~~~~ ~~~~
32 | ast::num(n) => *n,
| ~~~
test.rs:31:5: error: mismatched types, expected ‘& ast’ but got ‘ast’ [E0308]
31 | match node {
| ^~~~~ ~~~~
32 | ast::num(n) => *n,
33 | ast::add(l, r) => eval(l) + eval(r),
| ~~~
test.rs:40:22: error: mismatched types, expected ‘ast’ but got ‘ast’ [E0308]
27 | add(&'a ast<'a>, &'a ast<'a>),
| ~~~
......
40 | let c = ast::add(&a, &b);
| ^~
test.rs:42:23: error: cannot find value ‘c’ in this scope [E0425]
42 | let e = ast::add(&c, &d);
| ^
test.rs:42:22: error: failed to resolve argument type
42 | let e = ast::add(&c, &d);
| ^
test.rs:44:60: error: cannot find value ‘e’ in this scope [E0425]
44 | printf("%d\n\0" as *const str as *const i8, eval(&e) as i32);
| ^
- Dominant language
- C++
- Stars
- 3k
- Forks
- 238
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 31
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
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.
More from Rust-GCC/gccrs
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 3 days
-
Allow pattern matching of floating point literalsPossibly taken @Vivekkumar0995 claimed this 7 days ago. Opencleanup good-first-pr typechecking
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Rust-GCC/gccrs#5047 · 3 comments · 1 assignee ·
Maintainers usually reply within 3 days
-
ICE in variance analysis on core, projection field keeps the impl's type paramPossibly taken @u7k4rs6 claimed this 1 day ago. Opentypechecking
Rust-GCC/gccrs#5074 · 1 assignee ·
Maintainers usually reply within 3 days
-
subset-error typechecking
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Maintainers usually reply within 3 days
-
Difficulty 3/5 1-2 days Newbie friendliness 46/100
Rust-GCC/gccrs#5060 · 2 comments ·
Maintainers usually reply within 3 days
Similar issues
-
mlir
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
llvm/llvm-project#241070 · 1 comment ·
Maintainers usually reply within 1 day
-
backlog documentation
Difficulty 1/5 Under an hour Newbie friendliness 96/100
EchoTools/nevr-runtime#2354 ·
Maintainers usually reply within 1 day
-
help wanted new command
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tldr-pages/tldr#25111 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Ask the `ServerHelper` for fresh headers on every poll in `Future::get`, as is done for cookiesOpenenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
NVIDIA/cuda-quantum#5886 ·
Maintainers usually reply within 1 day