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

Session entered more than once only emits diagnostics in first execution #130

Open
ferranbt opened this issue Nov 18, 2024 · 1 comment
Open
Labels
C-enhancement Category: an issue proposing an enhancement or a PR with one

Comments

@ferranbt
Copy link
Contributor

Describe the feature

Entering a Session multiple times to parse a file only emits diagnostics on the first execution

let path = Path::new("src/Counter.sol");

let human = HumanEmitter::new(io::stdout(), solar_interface::ColorChoice::Auto);
let dcx = DiagCtxt::new(Box::new(human));

// Create a new session with a buffer emitter.
// This is required to capture the emitted diagnostics and to return them at the end.
let sess = Session::builder().dcx(dcx).build();

// Enter the context and parse the file. This session emits diagnostics
let _ = sess.enter(|| -> solar_interface::Result<()> {
  let mut pcx = solar_sema::ParsingContext::new(&sess);
  pcx.load_file(path).unwrap();
  pcx.parse_and_resolve();

  Ok(())
});

println!("Enter second session");

// Enter the second context and parse the file. This session DOES NOT emit diagnostics
let _ = sess.enter(|| -> solar_interface::Result<()> {
  let mut pcx = solar_sema::ParsingContext::new(&sess);
  pcx.load_file(path).unwrap();
  pcx.parse_and_resolve();

  Ok(())
});

Additional context

No response

@ferranbt ferranbt added C-enhancement Category: an issue proposing an enhancement or a PR with one S-needs-triage This issue needs to be labelled labels Nov 18, 2024
@DaniPopes
Copy link
Member

Identical diagnostics are deduplicated across an entire session, for now if you want a clean slate you should create a new session

We could provide a clear method that resets internal state

@DaniPopes DaniPopes removed the S-needs-triage This issue needs to be labelled label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: an issue proposing an enhancement or a PR with one
Projects
None yet
Development

No branches or pull requests

2 participants