-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plumbed spans through alias definitions, allowing for more precise er… #576
Conversation
…ror reporting of aliases conflicting with existing names Simplified implementation of `name_and_aliases` (and `name_and_aliases_spans`, which returns spans); now only allocates once, and return a concrete `impl Iterator` (not `Box<dyn Iterator>`)
I need help writing tests for this. |
For future work it would be interesting to report all conflicting identifiers in one go. For instance, |
I'm not sure we have tests that check against the full diagnostic output. It would be a good idea to have this though. Tests in numbat/tests/interpreter.rs probably come closes. Using insta-based snapshot tests for this would probably be a good idea. If numbat/tests/interpreter.rs doesn't work (no access to diagnostics), we can also put those kind of tests in numbat-cli/tests/intergration.rs. There, we should definitely have access to the full error output.
I think it's okay to go with just one for now. I don't think it's very common that you hit multiple in one go :-) |
I can help with creating tests for this (will take a few days though). |
Sorry. I was interrupted while working on this. Will try to fix the tests on all platforms later today. |
4e048d8
to
9612dd6
Compare
I reverted my changes. I tried to use Thank you very much for this. |
…ror reporting of aliases conflicting with existing names
Simplified implementation of
name_and_aliases
(andname_and_aliases_spans
, which returns spans); now only allocates once, and return a concreteimpl Iterator
(notBox<dyn Iterator>
)Closes #570
Before:
After:
I debated whether to point the “previously defined here” error span not to
year
itself but to the alias responsible,yr
, but thought that that was less helpful, as for more obscure aliases it won't be obvious what unit it is tied to (without usinginfo <alias>
). Also the line containing the alias often has lots of extraneous info such as other aliases or alias config. I think it's nicer to have the full chain of conflict laid out all the way back to the source, the original unit, which in theory should be quite obvious — everyone knows whatunit year: Time = 365.242_188_1 days
means.