Opened 18 years ago

#13 new defect

Patterns redefinition should not occur for packages in the inner parts of the use graph

Reported by: arnault Owned by: VG,CA
Priority: high Milestone: v1r18
Component: c. Core Version:
Severity: normal Keywords:
Cc: OS: All
If Other, could you precise: Experiment: Other
If Other, could you precise:
Stack trace:
Steps to reproduce:

Description

Patterns redefinition should not occur for packages in the inner parts of the use graph.

Let's consider the following scenario, with two packages A and B, each refering to a dedicated Policy package where a pattern P is defined or overridden:

B:
  use A
  use BPolicy
  apply_pattern P

A:
  use APolicy -> define pattern P
  apply_pattern P

[From B] cmt show pattern P
# BPolicy v1 defines pattern P as
  macro P<package> "vB"
# applied by A => 
macro PA vB
# B v1 applies pattern P => 
macro PB vB

In this scheme, we observe that package A applies the overridden version of pattern P although A never uses BPolicy.

Note that the order of uses is significant here:

If BPolicy is now used before A then the effect is inverse:

B:
  use BPolicy
  use A
  apply_pattern P

A:
  use APolicy -> define pattern P
  apply_pattern P

[from B] cmt show pattern P
# APolicy v1 defines pattern P as
  macro P<package> "vA"
# applied by A => 
macro PA vA
# B v1 applies pattern P => 
macro PB vA

In this precise case, the result is correct since the new definition (from APolicy) is properly taken into account from B.

This results from the current internal algorithm of CMT:

  • CMT first reads all requirements files, ie collects all pattern definitions, including overrding definitions
  • then it applies patterns to all used packages, using the final definition

We might rather prefer to apply patterns at each package level. Thus the expected result might rather be:

B:
  use A
  use BPolicy
  apply_pattern P

[from B] cmt show pattern P
# APolicy v1 defines pattern P as
  macro P<package> "vA"
# applied by A => 
macro PA vA
# B v1 applies pattern P => 
macro PB vB

and:

B:
  use BPolicy
  use A
  apply_pattern P

[from B] cmt show pattern P
# APolicy v1 defines pattern P as
  macro P<package> "vA"
# applied by A => 
macro PA vA
# B v1 applies pattern P => 
macro PB vA

Change History (0)

Note: See TracTickets for help on using tickets.