Skip to content
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

Invalidated diagnostics live forever #145

Open
brson opened this issue Mar 2, 2022 · 1 comment
Open

Invalidated diagnostics live forever #145

brson opened this issue Mar 2, 2022 · 1 comment

Comments

@brson
Copy link
Contributor

brson commented Mar 2, 2022

Updating source follows this pattern:

            self.db.update_file(self.filename, module_source.text);

            let diagnostics = self.db.diagnostics(self.filename);
            for diagnostic in &diagnostics {
                dada_error_format::print_diagnostic(self.db, &diagnostic)?;
            }

These diagnostics are "accumulated" by salsa. From what can tell these diagnostics stick around forever. If the source text changes then the diagnostics remain, but they reference text that no longer exists.

I have run into this in the repl, which continuously updates the source text.
At the moment the repl doesn't "commit" steps that fail to compile or run. That is, if enter foo() and foo doesn't exist, the repl will update the source to include a function that tries to call foo(), see that it fails and "revert" the changes so that call is no longer part of the source text. The result is that subsequent steps continue to observe that failed diagnostic, but it prints incorrectly:

>>> foo()
Error: can't find anything named `foo`
   ╭─[<repl-input>:2:17]
   │
 2 │ __repl_result = foo()
   ·                 ─┬─
   ·                  ╰─── here
───╯
compilation failed
>>> 4
Error: can't find anything named `foo`
   ╭─[<repl-input>:2:17]
   │
 2 │ ╭─▶ __repl_result = 4
 3 │ ├─▶ __repl_expr_1(__repl_result).await
   · │
   · ╰──────────────────────────────────────── here
───╯
compilation failed

Here the second step produces the same diagnostic but it is now pointing to different text.

I think I can mostly work around this behavior by ignoring previously-seen diagnostics, but this seems like a bug - the fixed diagnostic should disappear or otherwise be identifiable as invalidated.

@nikomatsakis
Copy link
Member

Yeah, the salsa branch we are based off of has some bugs =)

I've been putting off fixing them because I wanted to make progress on dada but ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants