@@ -1016,9 +1016,7 @@ internal virtual NewReference Invoke(BorrowedReference inst, BorrowedReference a
10161016 // If we already have an exception pending, don't create a new one
10171017 if ( ! Exceptions . ErrorOccurred ( ) )
10181018 {
1019- // A keyword argument whose name no candidate overload accepts gets the
1020- // Python-native "unexpected keyword argument" error: the generic no-match
1021- // message below does not echo kwargs, leaving the actual mistake invisible.
1019+ // Unknown kwarg names get the Python-style error; the generic message below does not echo kwargs.
10221020 if ( TryRaiseUnexpectedKeywordArgumentError ( kw , info , methodinfo ) )
10231021 {
10241022 return default ;
@@ -1132,11 +1130,8 @@ internal virtual NewReference Invoke(BorrowedReference inst, BorrowedReference a
11321130 }
11331131
11341132 /// <summary>
1135- /// When a bind failure involves a keyword argument whose name no candidate overload
1136- /// accepts, raises the Python-style "got an unexpected keyword argument" TypeError
1137- /// (with a "Did you mean" hint when a similarly-named parameter exists) and returns
1138- /// true. Returns false when every kwarg name is accepted by at least one overload,
1139- /// so the generic no-match error is raised instead.
1133+ /// Raises "got an unexpected keyword argument" and returns true when a kwarg name is
1134+ /// accepted by no candidate overload; returns false to let the generic no-match error be raised.
11401135 /// </summary>
11411136 private bool TryRaiseUnexpectedKeywordArgumentError ( BorrowedReference kw , MethodBase info , MethodInfo [ ] methodinfo )
11421137 {
@@ -1146,9 +1141,7 @@ private bool TryRaiseUnexpectedKeywordArgumentError(BorrowedReference kw, Method
11461141 return false ;
11471142 }
11481143
1149- // The same candidate set Bind considered: parameter names are snake_case for
1150- // snake_case-registered methods and original for the original ones, matching
1151- // the names the caller can actually use.
1144+ // Same candidate set Bind considered; ParameterNames are already in the caller's convention.
11521145 var methods = info == null
11531146 ? GetMethods ( )
11541147 : new List < MethodInformation > ( 1 ) { new MethodInformation ( info , true ) } ;
@@ -1206,10 +1199,8 @@ private bool TryRaiseUnexpectedKeywordArgumentError(BorrowedReference kw, Method
12061199 }
12071200
12081201 /// <summary>
1209- /// The candidate parameter name closest to the unexpected kwarg name, or null when
1210- /// none is similar enough to suggest. A candidate is considered when it is within
1211- /// a small edit distance of the name, or when one contains the other (e.g. 'as_tag'
1212- /// suggests 'tag'); containment requires 3+ characters so tiny names don't match.
1202+ /// Closest parameter name to suggest, or null: small edit distance, or containment
1203+ /// between names of 3+ characters (e.g. 'as_tag' suggests 'tag').
12131204 /// </summary>
12141205 private static string ClosestParameterName ( string name , HashSet < string > parameterNames )
12151206 {
@@ -1234,7 +1225,7 @@ private static string ClosestParameterName(string name, HashSet<string> paramete
12341225 return best ;
12351226 }
12361227
1237- // Case-insensitive Levenshtein distance, local to keyword suggestions .
1228+ // Case-insensitive Levenshtein distance.
12381229 private static int KeywordEditDistance ( string a , string b )
12391230 {
12401231 a = a . ToLowerInvariant ( ) ;
0 commit comments