#no field named 'x' in struct 'x'
1 messages · Page 1 of 1 (latest)
try it and see, what the optimizer decides to do is not something you can usually intuit
What do you mean? There is no such thing as method in a normal sense in Zig, it's merely a UCS ("universal call syntax", IIRC) convention, allowing to call a function using a dot. In the particular code above the error seems to me to occur merely because of a typo in the function's name, there is only rootDefinitions function but no parseDefinitions
That being said, there seems to be limits to using functions as values in Zig. I'm not sure where the limits are, it seems more robust to work with const function pointers instead (which syntactically work pretty much the same AFAIK).
Ah, wait, I was missing the line (it's a bit difficult to pinpoint the error due to missing line numbers)
const parseDefinitions = self.parseDefinitions;
Still, where is parseDefinitions in your Parser?
The reference manual refers to a.b() as calling the method b on the container instance a. It is worth noting that what they are asking about used to be possible, but the BoundFn type no longer exists.
I'm still not sure what the original code intends to do, but if rootDefinitions is meant instead of parseDefinitions then I think it should work as collectNodes(grammar.DefinitionNode, self, @This().rootDefinitions);
Or actually, simply
collectNodes(grammar.DefinitionNode, self, rootDefinitions);