Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"the type of this value must be known in this context" is fatal #2429

Closed
pcwalton opened this issue May 23, 2012 · 3 comments
Closed

"the type of this value must be known in this context" is fatal #2429

pcwalton opened this issue May 23, 2012 · 3 comments
Labels
A-typesystem Area: The type system
Milestone

Comments

@pcwalton
Copy link
Contributor

It shouldn't be.

@lkuper
Copy link
Contributor

lkuper commented Jun 21, 2012

The "the type of this value must be known in this context" error comes from the typeck::check::structurally_resolved_type() function. structurally_resolved_type() is supposed to take a type and return a one-level-resolved version of it. Right now, it will do that or die trying. If we just make this a non-fatal error, then structurally_resolved_type() will have no choice but to return the original type with unresolved type variables, and let other code deal with the consequences.

In particular, this means that in code like compile-fail/issue-2151.rs, where we currently just get

/home/lkuper/rust/src/test/compile-fail/issue-2151.rs:3:20: 3:21 error: the type of this value must be known in this context
/home/lkuper/rust/src/test/compile-fail/issue-2151.rs:3         log (debug, i * 2);
                                                                            ^

we'd instead get

/home/lkuper/rust/src/test/compile-fail/issue-2151.rs:3:20: 3:21 error: the type of this value must be known in this context
/home/lkuper/rust/src/test/compile-fail/issue-2151.rs:3         log (debug, i * 2);
                                                                            ^
/home/lkuper/rust/src/test/compile-fail/issue-2151.rs:3:20: 3:25 error: binary operation * cannot be applied to type `<V1>`
/home/lkuper/rust/src/test/compile-fail/issue-2151.rs:3         log (debug, i * 2);
                                                                            ^~~~~

A similar thing happens in compile-fail/issue-2150.rs and in compile-fail/issue-2149.rs. In all three cases, after the "type of this value must be known" error, we reach another error that's essentially a more specific version of it. Is this an improvement? Specificity = probably good, duplicate errors = meh, having to print type variables = probably bad...

@pcwalton
Copy link
Contributor Author

At the very least it should bail out of the current function and go on to typecheck other functions.

@catamorphism
Copy link
Contributor

This should be fixed by my work on derived errors. Report any further duplicate errors as a new bug.

celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

3 participants