File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -2839,6 +2839,23 @@ class AnyFunctionType : public TypeBase {
28392839
28402840 bool hasInternalLabel () const { return !InternalLabel.empty (); }
28412841 Identifier getInternalLabel () const { return InternalLabel; }
2842+
2843+ // / Return true if argument name is valid and matches \c paramName.
2844+ // /
2845+ // / The three tests to check if argument name is valid are:
2846+ // / 1. allow argument if it matches \c paramName,
2847+ // / 2. allow argument if $_ for omitted projected value label,
2848+ // / 3. allow argument if it matches \c paramName without its \c $ prefix.
2849+ bool matchParameterLabel (Identifier const ¶mName) const {
2850+ auto argLabel = getLabel ();
2851+ if (argLabel == paramName)
2852+ return true ;
2853+ if ((argLabel.str () == " $_" ) && paramName.empty ())
2854+ return true ;
2855+ if (argLabel.hasDollarPrefix () && argLabel.str ().drop_front () == paramName.str ())
2856+ return true ;
2857+ return false ;
2858+ }
28422859
28432860 ParameterTypeFlags getParameterFlags () const { return Flags; }
28442861
Original file line number Diff line number Diff line change @@ -291,13 +291,10 @@ static bool matchCallArgumentsImpl(
291291 assert (argIdx != numArgs && " Must have a valid index to claim" );
292292 assert (!claimedArgs[argIdx] && " Argument already claimed" );
293293
294- auto argLabel = args[argIdx].getLabel ();
295294 if (!actualArgNames.empty ()) {
296295 // We're recording argument names; record this one.
297296 actualArgNames[argIdx] = expectedName;
298- } else if (argLabel != expectedName && !ignoreNameClash &&
299- !(argLabel.str ().startswith (" $" ) &&
300- argLabel.str ().drop_front () == expectedName.str ())) {
297+ } else if (!ignoreNameClash && !args[argIdx].matchParameterLabel (expectedName)) {
301298 // We have an argument name mismatch. Start recording argument names.
302299 actualArgNames.resize (numArgs);
303300
You can’t perform that action at this time.
0 commit comments