Skip to content

fix: panic on assembler source manager mismatch (semver-compat)#3007

Closed
huitseeker wants to merge 6 commits intomainfrom
fix/2778-backcompat
Closed

fix: panic on assembler source manager mismatch (semver-compat)#3007
huitseeker wants to merge 6 commits intomainfrom
fix/2778-backcompat

Conversation

@huitseeker
Copy link
Copy Markdown
Collaborator

This is a version of #2987 that is semver-compatible.

@huitseeker huitseeker changed the base branch from next to main April 14, 2026 13:47
Copy link
Copy Markdown
Contributor

@Al-Kindi-0 Al-Kindi-0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming only the semver change is different from #2987

Copy link
Copy Markdown
Contributor

@Al-Kindi-0 Al-Kindi-0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this will need a deeper look by @bitwalker

Copy link
Copy Markdown
Collaborator

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes some assumptions about how source files are related to modules which are incorrect, so I don't think it makes sense to merge it (or #2987).

I'm not sure this is even the correct way to handle this in general - if you've somehow gotten your source managers mixed up, you want to know exactly where that happened, and a panic is useful for that. If you instead silently drop the source locations, or try to bubble up an Err, you'll lose valuable context about where the wires got crossed.

IMO, this is really a documentation issue related to how SourceManager impls need to be used, both from the caller perspective, and in terms of threading them through internals of the VM or other components.

/// The source file from which this module was parsed, if any.
///
/// Programmatically-constructed modules do not have a backing source file.
source_file: Option<Arc<SourceFile>>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two issues with this:

  1. Programmatically-constructed modules can absolutely have a backing source file - it just means that the source language was not Miden Assembly (or that the AST was literally constructed by hand for a test, but that's not the important case).
  2. Source spans within a Module do not have to come from the same source file, and in fact that is the common case when compiling from Rust source code currently.

@huitseeker
Copy link
Copy Markdown
Collaborator Author

@bitwalker OK, let's continue the discussion in #2987.

@huitseeker huitseeker closed this Apr 14, 2026
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

Successfully merging this pull request may close these issues.

4 participants