fmease / lushui

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

Namespaced literals: Internal error expression leaks into diagnostic #172

Open fmease opened 1 year ago

fmease commented 1 year ago

Given

use null.L
X: extern.core.type.Type = L.0

The error message goes as follows:

error[E021]: the binding ‘null’ is not defined in this scope
  ┌─ /home/fmease/programming/lushui/err.lushui:1:5
  │
1 │ use null.L
  │     ════

error: binding ‘L’ is not a data type
  ┌─ /home/fmease/programming/lushui/err.lushui:2:28
  │
2 │ X: extern.core.type.Type = L.0
  │                            ═ a error
  │
  ├─ /home/fmease/programming/lushui/err.lushui:2:30
  │
2 │ X: extern.core.type.Type = L.0
  │                              ─ literal requires a data type as its namespace

Ideally, we should not emit the second diagnostic at all. Apart from that, we should probably refactor how we display entity kinds (I assume). Even though entity kind Error (displayed as error) should not be leaked, we should use the correct article: an error, not a error.