fmease / lushui

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

Some irrelevant errors may be reported when the are conflicting attributes across a module declaration and its module header #117

Open fmease opened 2 years ago

fmease commented 2 years ago

In the normal case (when attributes aren't spread across module declaration and module header), we first filter duplicate/conflicting attributes before potentially showing more errors about the (first) attribute. Consider the expression @Int @Int @Nat 0, the output is:

error[E014]: attributes `Int` and `Nat` are mutually exclusive
 --> /home/fmease/programming/main_projects/lushui/y.lushui:1:13
  |
1 | main: Nat = @Int @Int @Nat 0
  |             ^^^^ conflicting attribute
  |
 --> /home/fmease/programming/main_projects/lushui/y.lushui:1:23
  |
1 | main: Nat = @Int @Int @Nat 0
  |                       ^^^^ conflicting attribute
  |

error[E006]: multiple `Int` attributes
 --> /home/fmease/programming/main_projects/lushui/y.lushui:1:13
  |
1 | main: Nat = @Int @Int @Nat 0
  |             ^^^^ duplicate or conflicting attribute
  |
 --> /home/fmease/programming/main_projects/lushui/y.lushui:1:18
  |
1 | main: Nat = @Int @Int @Nat 0
  |                  ^^^^ duplicate or conflicting attribute
  |

But for the anormal case, e.g:

@doc-attributes
module a of
    @doc-attributes
    module

It's:

error[E038]: attribute `doc-attributes` is an internal feature
 --> /home/fmease/programming/main_projects/lushui/rr.lushui:1:1
  |
1 | @doc-attributes
  | ^^^^^^^^^^^^^^^
  |

error[E006]: multiple `doc-attributes` attributes
 --> /home/fmease/programming/main_projects/lushui/rr.lushui:1:1
  |
1 | @doc-attributes
  | ^^^^^^^^^^^^^^^ duplicate or conflicting attribute
  |
 --> /home/fmease/programming/main_projects/lushui/rr.lushui:3:5
  |
3 |     @doc-attributes
  |     ^^^^^^^^^^^^^^^ duplicate or conflicting attribute
  |

error[E038]: attribute `doc-attributes` is an internal feature
 --> /home/fmease/programming/main_projects/lushui/rr.lushui:3:5
  |
3 |     @doc-attributes
  |     ^^^^^^^^^^^^^^^
  |

The error about the attribute being internal should only show up once.

See: https://github.com/fmease/lushui/blob/b96e3a1e893d637d5bdef8c08f5b53bb6b4334c9/src/syntax/lowerer.rs#L351-L359