Skip to content

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

Open
@ferranbt

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: an issue proposing an enhancement or a PR with one

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions