Skip to content

allow circular require #120

Description

@daurnimator

You can have interfaces that include each other:

interface foo
    bar: bar
end
interface bar
    foo: foo
end

However if I want to split that into two files (say, foo.tld and bar.tld), then tlc fails with type error, circular require

Activity

  1. mascarenhas commented on Aug 27, 2018

    @mascarenhas
    Collaborator

    The problem is that a Typed Lua require maps to a Lua require, and Lua does not allow circular module references. A possible solution would be for the Typed Lua compiler to notice when a module is only being required for its types (its members are only referenced in type declarations), and not emit a require in the generated Lua file for that case. The compiler would also need to defer the circular require error until the module doing the offending require has been analyzed and it knows whether this is a runtime require or not.

  2. daurnimator commented on Aug 27, 2018

    @daurnimator
    Author

    I feel like require here needs to act more like include

  3. mascarenhas commented on Aug 28, 2018

    @mascarenhas
    Collaborator

    Do you mean source file inclusion? Lua (and by extension Typed Lua) cannot really have circular requires with the way its modules work, so the exception would really have to be for modules that are required just for their types.

  4. daurnimator commented on Aug 28, 2018

    @daurnimator
    Author

    This was in reference to .tld files.

  5. mascarenhas commented on Aug 28, 2018

    @mascarenhas
    Collaborator

    Sorry, saw that part only now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions