]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xdrgen: Extend error reporting to AST transformation phase
authorChuck Lever <chuck.lever@oracle.com>
Fri, 26 Dec 2025 15:19:33 +0000 (10:19 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 26 Jan 2026 15:10:58 +0000 (10:10 -0500)
commit63a5425ff5e077c54eb2719c735108e2aa1f9eb6
treebbafb7b3c8af0231497a7624789c67e749c4c325
parent3e6397b056335cc56ef0e9da36c95946a19f5118
xdrgen: Extend error reporting to AST transformation phase

Commit 277df18d7df9 ("xdrgen: Improve parse error reporting") added
clean, compiler-style error messages for syntax errors detected during
parsing. However, semantic errors discovered during AST transformation
still produce verbose Python stack traces.

When an XDR specification references an undefined type, the transformer
raises a VisitError wrapping a KeyError. Before this change:

  Traceback (most recent call last):
    File ".../lark/visitors.py", line 124, in _call_userfunc
      return f(children)
    ...
  KeyError: 'fsh4_mode'
  ...
  lark.exceptions.VisitError: Error trying to process rule "basic":
  'fsh4_mode'

After this change:

  file.x:156:2: semantic error
  Undefined type 'fsh4_mode'

       fsh4_mode mode;
              ^

The new handle_transform_error() function extracts position information
from the Lark tree node metadata and formats the error consistently with
parse error messages.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
tools/net/sunrpc/xdrgen/subcmds/declarations.py
tools/net/sunrpc/xdrgen/subcmds/definitions.py
tools/net/sunrpc/xdrgen/subcmds/lint.py
tools/net/sunrpc/xdrgen/subcmds/source.py
tools/net/sunrpc/xdrgen/xdr_parse.py