Skip to content

[feat] add a hint to `HasField` error message

  • are either individually buildable or squashed
  • have commit messages which describe what they do (referring to [Notes][notes] and tickets using #NNNN syntax when appropriate)
  • have added source comments describing your change. For larger changes you likely should add a [Note][notes] and cross-reference it from the relevant places.
  • add a testcase to the testsuite.

This is a first step in addressing the issue #22382 by adding a hint.

  • if the Record is known (i.e. we know the type's constructor)
  • the record has at least one constructor ("it is a record")
  • the error message will look as follows:
    • No instance for ‘HasField "quux" Quux a0’
          arising from selecting the field ‘quux’
        NB: There is no field selector ‘quux :: Quux -> a0’ in scope 
  • I do not show this on unknown type, most importantly because it is hard to read the intention of the programmer, because one could always have handwritten HasField instances.
Edited by Magnus Viernickel

Merge request reports