[3.9] Validate the AST produced by the parser in debug mode (GH-21643) (GH-21646)

This will improve the debug experience if something fails in the produced AST. Previously, errors in the produced AST can be felt much later like in the garbage collector or the compiler, making debugging them much more difficult..
(cherry picked from commit 1332226b32da44087a55e1d71990ee6899dfd28a)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 file changed