Open beuss-git opened 2 weeks ago
Hi, the author of #1715 here. I also wondered why it's not done like this, since factoring out a mixin wasn't the best option, but it was the only one, that made everything work with the current IDL Parser, I also wonder, if there is any spec regarding IDL and the parsing order of it.
It works like I did it, and it doesn't seem to be a problem anywhere else, so I am not sure how urgent this is, or if it just is a one time problem 🤷🏼♂️
Hey, I was wondering if the IDLParser should be able to handle circular imports.
The
Parser::resolve_import()
method in IDLParser.cpp does have a check for circular imports, but afaict it will never executed because when we do have a circular import, thetop_level_resolved_imports()
value will always contain the interface path as it is added there at the start ofParser::parse()
which is recursively called inParser::resolve_import()
.This hasn't proved to be much of an issue though, and a lot of code seems to rely on circular imports such as CSSRule.idl <-> CSSStyleSheet.idl. I have attached a file containing a list of all the circular dependencies I could find here: circular_dependencies.txt (there are at least 51 cases).
The issue happens when we add mixins. And I first noticed it based on the work in #1715 because he had to separate out the mixin interface.
Currently the following happens when parsing an idl file:
top_level_resolved_imports()
tabletop_level_resolved_imports()
, return it.Here is an example: A.idl
B.idl
We start by parsing A.idl, then the issue happens in step 4 when we are parsing B.idl in the recursive call to parse. B.idl at this point is happy with its imports, namely A.idl since it was added to the top level imoprts, but since A.idl hasn't actually been parsed, it reports that it has no mixins in its idl file. So B.idl will then complain that there exists no mixin named
C
.If we just remove this line
report_parsing_error(ByteString::formatted("Mixin '{}' was never defined", entry), filename, input, lexer.tell());
everything seems to still be working and the interfaces that include the mixin still get the mixin attributes. I guess this happens when we generate the bindings for each IDL individually.I don't know the system well enough to tell what other implications this has.
Should anything be done with this?