fmease / lushui

The reference compiler of the Lushui programming language
Apache License 2.0
5 stars 0 forks source link

Disallow restricted exposure for compontent root #97

Open fmease opened 3 years ago

fmease commented 3 years ago

The component root is implicitly public (i.e. has unrestricted exposure). Thus, the following should stay legal:

@public
module

But code like the one below should not be legal:

@(public topmost)
module
@(public topmost.some.path.to.somewhere)
module

The check could of course be implemented in the lowerer but I'd rather do it in the name resolver.

Not sure if we should check this during lowering or in the name resolver. Probably in the name resolver.

fmease commented 3 years ago

Btw, what happens with this code?:

;;; escape.lushui:
@(public self.escape) module

Can one access the component name this way??

fmease commented 2 years ago

This appears to be fixed since we disallow @public on module headers:

error[E013]: attribute `public` is ascribed to a module header declaration
 --> /home/fmease/programming/main_projects/lushui/component-name.lushui:1:1
  |
1 | @(public self.component-name)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ misplaced attribute
  |
 --> /home/fmease/programming/main_projects/lushui/component-name.lushui:2:1
  |
2 | module
  | ------ incompatible item
  |
 note: attribute `public` can only be ascribed to declarations except constructors and module headers

Leaving this issue open since we should document this in the code (that the specific AttributeTargets where chosen to prevent restricting the exposure of the component root).