mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Align duplicate-parameter diagnostics with Python 3.15 (#9287)
* Align duplicate-parameter diagnostics with Python 3.15 Preserve source names and locations in both symbol-table paths, and migrate the existing canonical codeop expectation through update_lib. Assisted-by: OpenAI Codex: model version unavailable * Sync positional-only duplicate-parameter expectations Migrate the full pinned CPython 3.15.0 test file through update_lib. Its only delta is six existing expected messages, completing the dependent canonical wording coverage. Assisted-by: OpenAI Codex: model version unavailable
This commit is contained in:
1 parent
3b87cbe559
commit
5aab0db07d
3 files changed
+11
-11
No files matched your search
Vendored
+1
-1
@@ -373,7 +373,7 @@ class CodeopTests(unittest.TestCase):
|
||||
def foo(x,x):
|
||||
pass
|
||||
""")
|
||||
message = "duplicate argument 'x' in function definition"
|
||||
message = "duplicate parameter 'x' in function definition"
|
||||
with self.assertRaisesRegex(SyntaxError, message):
|
||||
compiler(code, "<input>", 'exec')
|
||||
|
||||
|
||||
Vendored
+6
-6
@@ -37,8 +37,8 @@ class PositionalOnlyTestCase(unittest.TestCase):
|
||||
check_syntax_error(self, "def f(/): pass")
|
||||
check_syntax_error(self, "def f(*, a, /): pass")
|
||||
check_syntax_error(self, "def f(*, /, a): pass")
|
||||
check_syntax_error(self, "def f(a, /, a): pass", "duplicate argument 'a' in function definition")
|
||||
check_syntax_error(self, "def f(a, /, *, a): pass", "duplicate argument 'a' in function definition")
|
||||
check_syntax_error(self, "def f(a, /, a): pass", "duplicate parameter 'a' in function definition")
|
||||
check_syntax_error(self, "def f(a, /, *, a): pass", "duplicate parameter 'a' in function definition")
|
||||
check_syntax_error(self, "def f(a, b/2, c): pass")
|
||||
check_syntax_error(self, "def f(a, /, c, /): pass")
|
||||
check_syntax_error(self, "def f(a, /, c, /, d): pass")
|
||||
@@ -59,8 +59,8 @@ class PositionalOnlyTestCase(unittest.TestCase):
|
||||
check_syntax_error(self, "async def f(/): pass")
|
||||
check_syntax_error(self, "async def f(*, a, /): pass")
|
||||
check_syntax_error(self, "async def f(*, /, a): pass")
|
||||
check_syntax_error(self, "async def f(a, /, a): pass", "duplicate argument 'a' in function definition")
|
||||
check_syntax_error(self, "async def f(a, /, *, a): pass", "duplicate argument 'a' in function definition")
|
||||
check_syntax_error(self, "async def f(a, /, a): pass", "duplicate parameter 'a' in function definition")
|
||||
check_syntax_error(self, "async def f(a, /, *, a): pass", "duplicate parameter 'a' in function definition")
|
||||
check_syntax_error(self, "async def f(a, b/2, c): pass")
|
||||
check_syntax_error(self, "async def f(a, /, c, /): pass")
|
||||
check_syntax_error(self, "async def f(a, /, c, /, d): pass")
|
||||
@@ -247,8 +247,8 @@ class PositionalOnlyTestCase(unittest.TestCase):
|
||||
check_syntax_error(self, "lambda /: None")
|
||||
check_syntax_error(self, "lambda *, a, /: None")
|
||||
check_syntax_error(self, "lambda *, /, a: None")
|
||||
check_syntax_error(self, "lambda a, /, a: None", "duplicate argument 'a' in function definition")
|
||||
check_syntax_error(self, "lambda a, /, *, a: None", "duplicate argument 'a' in function definition")
|
||||
check_syntax_error(self, "lambda a, /, a: None", "duplicate parameter 'a' in function definition")
|
||||
check_syntax_error(self, "lambda a, /, *, a: None", "duplicate parameter 'a' in function definition")
|
||||
check_syntax_error(self, "lambda a, /, b, /: None")
|
||||
check_syntax_error(self, "lambda a, /, b, /, c: None")
|
||||
check_syntax_error(self, "lambda a, /, b, /, c, *, d: None")
|
||||
|
||||
@@ -1455,7 +1455,7 @@ impl SymbolTableBuilder {
|
||||
if table.symbols.contains_key(parameter.name.as_str()) {
|
||||
return Err(self.error_ranged(
|
||||
format!(
|
||||
"duplicate argument '{}' in function definition",
|
||||
"duplicate parameter '{}' in function definition",
|
||||
parameter.name
|
||||
),
|
||||
parameter.name.range,
|
||||
@@ -3204,7 +3204,7 @@ impl SymbolTableBuilder {
|
||||
|
||||
if matches!(role, SymbolUsage::Parameter) && flags.contains(SymbolFlags::DEF_PARAM) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("duplicate argument '{original_name}' in function definition"),
|
||||
error: format!("duplicate parameter '{original_name}' in function definition"),
|
||||
location,
|
||||
end_location,
|
||||
});
|
||||
@@ -3485,11 +3485,11 @@ mod tests {
|
||||
#[test]
|
||||
fn duplicate_parameter_check_uses_mangled_name_like_cpython() {
|
||||
let err = scan_source_result("class C:\n def f(__x, _C__x):\n pass\n")
|
||||
.expect_err("expected duplicate argument after class-private mangling");
|
||||
.expect_err("expected duplicate parameter after class-private mangling");
|
||||
|
||||
assert_eq!(
|
||||
err.error,
|
||||
"duplicate argument '_C__x' in function definition"
|
||||
"duplicate parameter '_C__x' in function definition"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user