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

Duplicate Pattern Bug #1275

Closed
stefjoosten opened this issue Feb 8, 2022 · 3 comments
Closed

Duplicate Pattern Bug #1275

stefjoosten opened this issue Feb 8, 2022 · 3 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior component: compiler priority:normal

Comments

@stefjoosten
Copy link
Contributor

stefjoosten commented Feb 8, 2022

What happened

Ampersand allows duplicate patterns, such as:

CONTEXT Issue1275

   PATTERN Foo
   RELATION r[A*B]
   ENDPATTERN

   PATTERN Foo
   RELATION s[A*B]
   ENDPATTERN

ENDCONTEXT

However, the above script produces a duplicate label error and causes Pandoc to crash in the most unelegant manner:

Duplicate label: fig:Concept diagram of relations in Foo
CallStack (from HasCallStack):
  error, called at lib-internal/Text/Pandoc/CrossRef/References/Blocks.hs:408:7 in pandoc-crossref-0.3.12.1-915mUtUhCDjEpzbcfysd1C-pandoc-crossref-internal:Text.Pandoc.CrossRef.References.Blocks
ampersand: Duplicate label: fig:Concept diagram of relations in Foo
CallStack (from HasCallStack):
  error, called at lib-internal/Text/Pandoc/CrossRef/References/Blocks.hs:408:7 in pandoc-crossref-0.3.12.1-915mUtUhCDjEpzbcfysd1C-pandoc-crossref-internal:Text.Pandoc.CrossRef.References.Blocks

What I expected

Since the inception of Ampersand, the formal semantics of this is the union of the contents of this pattern. So the script should behave exactly the same as:

CONTEXT Issue1275

   PATTERN Foo
   RELATION r[A*B]
   RELATION s[A*B]
   ENDPATTERN

ENDCONTEXT

Version of ampersand that was used

Ampersand-v4.6.2 [51c3de2:refs/tags/v4.6.2]

Steps to reproduce

I ran the bug using the ampersandtarski/ampersand:v4.6.2 image.

sjo00577@BA92-VYF9TXMD9G Ampersand % docker run -it --platform=linux/amd64 -v "$(pwd)":/scripts ampersandtarski/ampersand:v4.6.2 documentation --format docx Issue1275.adl
Generating functional design document for Issue...
/scripts/images/TechnicalDataModel.gv written.
/scripts/images/TechnicalDataModel.png written.
/scripts/images/LogicalDataModel.gv written.
/scripts/images/LogicalDataModel.png written.
/scripts/images/LogicalDataModel_Grouped_By_Pattern.gv written.
/scripts/images/LogicalDataModel_Grouped_By_Pattern.png written.
/scripts/images/Classification.gv written.
/scripts/images/Classification.png written.
/scripts/images/CDConceptONE.gv written.
/scripts/images/CDConceptONE.png written.
/scripts/images/CDConceptB.gv written.
/scripts/images/CDConceptB.png written.
/scripts/images/CDConceptA.gv written.
/scripts/images/CDConceptA.png written.
/scripts/images/CDPatternFoo.gv written.
/scripts/images/CDPatternFoo.png written.
/scripts/images/CDPatternFoo.gv written.
/scripts/images/CDPatternFoo.png written.
/scripts/images/RelationsInPatternFoo.gv written.
/scripts/images/RelationsInPatternFoo.png written.
/scripts/images/RelationsInPatternFoo.gv written.
/scripts/images/RelationsInPatternFoo.png written.
Generating docx to : ./Issue1275.docx
Duplicate label: fig:Concept diagram of relations in Foo
CallStack (from HasCallStack):
  error, called at lib-internal/Text/Pandoc/CrossRef/References/Blocks.hs:408:7 in pandoc-crossref-0.3.12.1-915mUtUhCDjEpzbcfysd1C-pandoc-crossref-internal:Text.Pandoc.CrossRef.References.Blocks
ampersand: Duplicate label: fig:Concept diagram of relations in Foo
CallStack (from HasCallStack):
  error, called at lib-internal/Text/Pandoc/CrossRef/References/Blocks.hs:408:7 in pandoc-crossref-0.3.12.1-915mUtUhCDjEpzbcfysd1C-pandoc-crossref-internal:Text.Pandoc.CrossRef.References.Blocks
sjo00577@BA92-VYF9TXMD9G Ampersand % 
@stefjoosten stefjoosten added bug Indicates an unexpected problem or unintended behavior component: compiler priority:normal labels Feb 8, 2022
@stefjoosten
Copy link
Contributor Author

stefjoosten commented Feb 8, 2022

The process for this bug

This bug has an easy workaround: just don't use duplicate pattern names. As a consequence, the priority of this bug cannot be 'high'. So I qualified it as 'normal'.

After fixing this bug, I suggest we add the script Issue1275.adl to the test set .../Ampersand/testing/Travis/testcases/FuncSpec/. (I have verified that this reproduces the bug in v4.6.2). For now, I'm have added the script to .../Ampersand/testing/StillUnsupported in branch issue-1275.

@stefjoosten stefjoosten self-assigned this Feb 8, 2022
@stefjoosten
Copy link
Contributor Author

stefjoosten commented Feb 8, 2022

Analysis

Two patterns that have the same name must be the same pattern.
However, in the parse tree (the P-structure) different patterns in the same context can have the same name.
So ADL2FSpec.hs is the place where patterns with the same name should be merged.

We need a new function to merge two Patterns and we need to use that in the construction of the Fspec.
That should do the trick.

@stefjoosten
Copy link
Contributor Author

@hanjoosten has solved this issue in commit 53522bf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior component: compiler priority:normal
Projects
None yet
Development

No branches or pull requests

1 participant