I will go for NOT loading (which I think also leads to simpler code; no getparamnode_nofollow needed).
Or maybe it's not simpler :-(
I have now a patch that loads references with subscripts only at access time. Thus the following example leads to an error:
() {
typeset -n ref=SRANDOM[1,20];
typeset -h SRANDOM=local-variable
echo START
echo $ref
echo END
}
Output:
START
(anon):4: Can't add module parameter `SRANDOM': local parameter exists
(anon):zsh/random:4: error when adding parameter `SRANDOM'
(anon):4: autoloading module zsh/random failed to define parameter: SRANDOM
However the following script still loads SRANDOM at definition time:
() {
typeset -n ref=SRANDOM;
typeset -h SRANDOM=local-variable
echo $ref
echo $SRANDOM
}
Output:
4184917433
local-variable
Preventing this one from loading SRANDOM at definition time would be rather difficult at the moment. It might become easier once my simplification patches are in but for the time being, I will rather ensure that the first script also loads SRANDOM at definition time. Because surely both scripts should at least behave the same way.
If we desire the non loading behavior, we can revisit this once the code is smaller and simpler.
I will send the patch once I have cleaned it up and added tests. It may only be in 2-3 days as I might be busy the next 2 days.
Philippe