Quirkiness with ModifyGraph

I do the following(simplified example) in a function and it doesnt work, giving me the error that the trace is not on the graph:
string w_name = "awesome_wave" make/o/d/n=10 $w_name wave w = $w_name w = (insert whatever data function here) display w modifygraph rgb(w)=(0,0,0)

but changing the modify line to this does:

modifygraph rgb($w_name) = (0,0,0)

Am I doing something wrong or is that working as intended? Thought my proxy wave handle "w" should work in all sorts of assignments.
Yes, it's working as intended. The important distinction here is 'wave reference' versus 'trace name'. Your 'w' provides the former; all functions acting on trances (including ModifyGraph) expect the latter.
The error in the first example comes from the fact that there is not trace named 'w' on the graph.
Note, that your 'fix' is not foolproof, as providing the wave name may be coincidental with the trace name, but not necessary always so (e.g., when a wave is appended twice). You may want to actually grasp the trace name directly from the graph (e.g., via TraceNameList).
To understand the trace name / wave reference distinction, execute this:
DisplayHelpTopic "Programming With Trace Names"