private static void WarnAboutMissingDollarSigns(LNodeList argList, IMacroContext context, LNode pattern, LNode replacement) { // Warn if a name appears in both pattern and replacement but uses $ in only one of the two. Dictionary <Symbol, LNode> pVars = ScanForVariables(pattern), rVars = ScanForVariables(replacement); // Also warn if it looks like all `$`s were forgotten. bool allIds = argList.Count > 0 && argList.All(n => !n.IsCall); foreach (var pair in pVars) { LNode rVar = rVars.TryGetValue(pair.Key, null); if (pair.Value.IsId) // id without `$` in pattern list { if (rVar != null && (allIds || !rVar.IsId)) { context.Sink.Warning(pair.Value, "`{0}` is written without `$`, so it may not match as intended.", pair.Value.Name); } } else // $id in pattern list { if (rVar != null && rVar.IsId) { context.Sink.Warning(rVar, "`{0}` appears in the output without `$` so replacement will not occur.", pair.Key); } } } }