File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -318,9 +318,25 @@ void CheckArgumentValidity()
318318 FlowBase . Argument flowArg = targetFlow . arguments [ i ] ;
319319 Parsed . Expression divArgExpr = arguments [ i ] ;
320320
321+ // Expecting a divert target as an argument, let's do some basic type checking
321322 if ( flowArg . isDivertTarget ) {
322- if ( ! ( divArgExpr is VariableReference || divArgExpr is DivertTarget ) ) {
323- Error ( "Target '" + targetFlow . name + "' expects a divert target for the parameter named -> " + flowArg . name + " but saw " + divArgExpr , divArgExpr ) ;
323+
324+ // Not passing a divert target or any kind of variable reference?
325+ var varRef = divArgExpr as VariableReference ;
326+ if ( ! ( divArgExpr is DivertTarget ) && varRef == null ) {
327+ Error ( "Target '" + targetFlow . name + "' expects a divert target for the parameter named -> " + flowArg . name + " but saw " + divArgExpr , divArgExpr ) ;
328+ }
329+
330+ // Passing 'a' instead of '-> a'?
331+ // i.e. read count instead of divert target
332+ else if ( varRef != null ) {
333+
334+ // Unfortunately have to manually resolve here since we're still in code gen
335+ var knotCountPath = new Path ( varRef . path ) ;
336+ Parsed . Object targetForCount = knotCountPath . ResolveFromContext ( varRef ) ;
337+ if ( targetForCount != null ) {
338+ Error ( "Passing read count of '" + knotCountPath . dotSeparatedComponents + "' instead of a divert target. You probably meant '" + knotCountPath + "'" ) ;
339+ }
324340 }
325341 }
326342 }
You can’t perform that action at this time.
0 commit comments