Conversation
7868a52 to
c04903a
Compare
8ca35cf to
ead119c
Compare
e6adf79 to
9df6b6d
Compare
9df6b6d to
b84d2d8
Compare
|
|
||
| elseif tag == "ast.Stat.Break" then | ||
| -- empty | ||
| elseif tag == "ast.Stat.Require" then |
There was a problem hiding this comment.
Consider adding a comment to remind that Require only accepts string literals, and thus there are no "exp" children to visit.
| Array = {"loc", "subtype"}, | ||
| Table = {"loc", "fields"}, | ||
| Function = {"loc", "arg_types", "ret_types"}, | ||
| QualifiedName = {"loc", "module", "name"}, |
There was a problem hiding this comment.
Question: would it be better or would it be worse if we had a single constructor for both names and qualified names?
E.g. setting the module as nil for unqualified names, or representing qualified names as a dotted string.
There was a problem hiding this comment.
I can't clearly see any disadvantages neither on having a QualifiedName constructor, nor adding a new field "module" to the Name constructor. I'd say I prefere the new constructor as it provides more explicit handling of that particular case and clearly distinguishes it from simple names. Do you have an opinion/preference on that?
or representing qualified names as a dotted string.
While that could also work, I'd avoid due to this drawback: although we could recognize and store the dotted string as the Name identifier with no problem, there would be no straightforward way to verify if the name is qualified or not other than looking for a dot in the string.
There was a problem hiding this comment.
I don't have a strong preference. Let's go ahead with QualifiedName then.
One possible advantage is that this way it is is probably more difficult to accidentally treat a qualified name as if it were not qualified, because we don't have to do another if statement inside the branch that handles the Name constructor.
| end | ||
| elseif def._tag == "typechecker.Def.Import" then | ||
| -- TODO: Handle module imported fields | ||
| return ir.Value.Nil -- added just so the compiler don't break while this case is not implemented |
There was a problem hiding this comment.
maybe it's OK to break it? There is already a flag to generate the module file without running the to_ir
a4d8713 to
b9b25b4
Compare
* `modname` -> `module_name` * extract imported type symbol checking to `try_access_qualified_type`
b9b25b4 to
168329b
Compare
-- Draft PR --
This PR adds partial support for the
requirecommand in the compiler's frontend