From 83b07aee39b054759ac3afde861ef9521dab8887 Mon Sep 17 00:00:00 2001 From: Victor Lanvin Date: Fri, 1 Nov 2024 04:03:29 -0700 Subject: [PATCH] Clarify map type approximation in errors Summary: Add a clarification that a map type will be approximated to `#{dynamic() => dynamic()}` in `bad_map_key` errors. Reviewed By: ilya-klyuchnikov Differential Revision: D65278382 fbshipit-source-id: 74cb9e7eeaa8b1184c845c2eab4c10cd3161ff01 --- .../whatsapp/eqwalizer/ast/InvalidDiagnostics.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/ast/InvalidDiagnostics.scala b/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/ast/InvalidDiagnostics.scala index 33bbfce..696fe01 100644 --- a/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/ast/InvalidDiagnostics.scala +++ b/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/ast/InvalidDiagnostics.scala @@ -77,11 +77,14 @@ object InvalidDiagnostics { } case class BadMapKey(pos: Pos, required: Boolean) extends Invalid { val msg: String = { - if (required) { - s"Required map key should always be composed of statically defined atoms or tuples." - } else { - s"Only one default association per map is allowed, all other keys should be composed of statically defined atoms or tuples." + val reason: String = { + if (required) { + s"Required map key should always be composed of statically defined atoms or tuples." + } else { + s"Only one default association per map is allowed, all other keys should be composed of statically defined atoms or tuples." + } } + s"Map type will be approximated to #{dynamic() => dynamic()}, suppressing potential errors.\n${reason}" } def errorName = "bad_map_key" }