From e2e1c2b705fcafdee78a67d164d3bcd7da58c7a2 Mon Sep 17 00:00:00 2001 From: Zanie Date: Fri, 14 Jul 2023 12:03:34 -0500 Subject: [PATCH] Add test for parenthized multiline type as identifier --- parser/src/parser.rs | 3 ++ ...er__parser__tests__type_as_identifier.snap | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/parser/src/parser.rs b/parser/src/parser.rs index 58ff722..d5bb7d3 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -952,6 +952,9 @@ a = ( a = ( type(b) ) +type ( + X = int +) "#; insta::assert_debug_snapshot!(ast::Suite::parse(source, "").unwrap()); } diff --git a/parser/src/snapshots/rustpython_parser__parser__tests__type_as_identifier.snap b/parser/src/snapshots/rustpython_parser__parser__tests__type_as_identifier.snap index c8cec12..53d337a 100644 --- a/parser/src/snapshots/rustpython_parser__parser__tests__type_as_identifier.snap +++ b/parser/src/snapshots/rustpython_parser__parser__tests__type_as_identifier.snap @@ -936,4 +936,43 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" type_comment: None, }, ), + Expr( + StmtExpr { + range: 599..616, + value: Call( + ExprCall { + range: 599..616, + func: Name( + ExprName { + range: 599..603, + id: Identifier( + "type", + ), + ctx: Load, + }, + ), + args: [], + keywords: [ + Keyword { + range: 607..614, + arg: Some( + Identifier( + "X", + ), + ), + value: Name( + ExprName { + range: 611..614, + id: Identifier( + "int", + ), + ctx: Load, + }, + ), + }, + ], + }, + ), + }, + ), ]