rustc sometimes resolves an ambiguous generic parameter instead of erroring #91369
Labels
A-inference
Area: Type inference
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Apologies that I don't have a minimum reproduction but I've tried a few ways and thus far failed to reproduce outside of the original crate.
We recently had an error where we were deserializing a dummy object for backwards-compatibility, but the type being read was ambiguous, causing the code to behave unexpectedly. For some reason rustc concretized the object to an
Option<()>
(guessing based on{:?}
output, as I can't tell why it was concretized) when it was ambiguous (we really wanted anOption<u64>
but didn't specify it).You can see the change which fixes it at lightningdevkit/rust-lightning#1195, which makes pretty clear that the object's type was, in fact, ambiguous (switching the changed declaration to
None::<()>
works just as well, while changing behavior). Theread_tlv_fields
macro isn't all that complicated - https://github.com/lightningdevkit/rust-lightning/blob/main/lightning/src/util/ser_macros.rs#L332 - it basically just calls intodecode_tlv_stream
which is pretty straightforward - https://github.com/lightningdevkit/rust-lightning/blob/main/lightning/src/util/ser_macros.rs#L168.I tried (and failed) to get a minimum reproduction which at least shows the high-level code structure at https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=c873827053afdaa20d333703d00fd16f (the actual relevant things are mostly in
util::ser
andutil::ser_macros
in the real code).The text was updated successfully, but these errors were encountered: