mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 17:52:58 +01:00
When a pattern is an error, avoid wrapping it as a subpattern in a RefParamPattern or VarPattern. This allows further error handling to observe the error occurred without having to unwrap it. This avoids a crash when an invalid associated constant is written which has a VarPattern in it. The associated constant machinery expects an AssociatedConstantDecl but was getting a VarPattern with an ErrorInst inside. Now it receives an ErrorInst directly, which it is already looking for. This choice means that `var` statements in an `interface` will always be diagnosed as being non-constant, or as being a constant with a `var`, so we don't need an extra diagnostic saying that `var` is not allowed in an interface, as this just leads to two diagnostics on the same thing. This crash was found by a fuzzer.