Skip to content

Improved `Did you mean?` in KatScript error messages

Fixes #404 (closed)

In ModelAttributeError it no longer suggests every attribute but only the ones that have either been dynamically added to a Model object (this should be all the model elements) or are a parameter (by using the parameters attribute).

Also adds Did you mean? to KatSyntaxError for elements and actions.

Also adds a filtering for class attributes like __dict__, Model.parse etc., to prevent confusing error messages later in the pipeline

Examples:

Current Develop

develop

line 1: unknown element 'lasser'
-->1: lasser l1 
      ^^^^^^

line 1: unknown element 'a'
-->1: a l1 
      ^

line 2: unknown function 'taxis'
   1: l l1 
-->2: taxis()
      ^^^^^

line 1: 'l' argument must be a string or a real number, not 'method'
-->1: l l1 P=parse
      ^^^^^^^^^^^^
Syntax: l name P=1 f=0 phase=0 signals_only=false

This branch

line 1: unknown element 'lasser'

Did you mean 'laser'?
-->1: lasser l1 
      ^^^^^^

line 1: unknown element 'a'

Did you mean 'ad', 'l', 'm', 's', or 'w'?
-->1: a l1

line 2: unknown function 'taxis'

Did you mean 'xaxis'?
   1: l l1 
-->2: taxis()
      ^^^^^

line 1: Model path `parse` resolves to class attribute.
-->1: l l1 P=parse
             ^^^^^
Edited by Miron van der Kolk

Merge request reports