Skip to content

Conversation

@JPier34
Copy link

@JPier34 JPier34 commented Jan 29, 2026

Description

This PR fixes the incorrect precedence rules in the import remapping documentation that contradict the actual compiler implementation.

Problem

The documentation at https://docs.soliditylang.org/en/v0.8.33/path-resolution.html#import-remapping incorrectly states that when multiple remappings match, "the one with the longest matching prefix is chosen."

However, the actual implementation in libsolidity/interface/ImportRemapper.cpp (lines 42-69) prioritizes context length first, not prefix length.

Solution

Updated the documentation in docs/path-resolution.rst to correctly reflect the actual precedence order:

  1. Context length (longest first) - highest priority
  2. Prefix length (longest first, if context is equal) - second priority
  3. Latest remapping (if both are equal) - lowest priority

Changes Made

  • Line 632: Changed "longest matching prefix" → "longest matching context"
  • Added new rule: "If contexts are identical, the one with the longest matching prefix is chosen."
  • Line 634: Updated "If prefixes are identical" → "If contexts and prefixes are identical"

References

Fixes #16383

Related code: https://github.com/argotorg/solidity/blob/develop/libsolidity/interface/ImportRemapper.cpp#L42-L69

@github-actions
Copy link

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import remapping docs incorrectly state prefix takes precedence over context

2 participants