Mercury Bugs - mercury | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0000538 | mercury | Bug | public | 2021-09-13 00:13 | 2021-09-13 05:34 |
Reporter | dirkz | ||||
---|---|---|---|---|---|
Assigned To | zs | ||||
Priority | low | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Platform | mercury-srcdist-rotd-2021-09-08 | OS | macOS Catalina | OS Version | 10.15.7 |
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0000538: Compiler does not recognise a chained subtype definition | ||||
Description | Example: ======== % Html content categories modelled as subtypes (simplified) % 1. All html elements belong to the base type flow_content % 2. Phrasing_content is a subset of flow_content % 3. Nesting of a-elements (hyperlinks) is invalid. Neither direct nor % indirect nesting is allowed. % :- type flow_content ---> p(list(phrasing_content)) ; div(list(flow_content)) ; a(list(flow_content_without_a)) ; text(string). :- type flow_content_without_a =< flow_content ---> p(list(phrasing_content_without_a)) ; div(list(flow_content_without_a)) ; text(string). :- type phrasing_content =< flow_content ---> a(list(phrasing_content_without_a)) ; text(string). % 1. Explicitly declared subtype of phrasing_content % 2. Implicit subtype of flow_content_without_a, because both share the % same base type (flow_content) and the subtype only omits constructor % definitions % :- type phrasing_content_without_a =< phrasing_content ---> text(string). Expected result: ================ The module should compile without error. Actual result: ============== Compiler error. Mercury does not recognise the implicit (undeclared) subtype relationship between subtype phrasing_content_without_a and its supertype flow_content_without_a. The subtype definition is valid, because both share the same base type (flow_content) and phrasing_content_without_a only omits constructor definitions of flow_content_without_a. $ mmc --make subtype Making Mercury/int3s/subtype.int3 Making Mercury/ints/subtype.int Making Mercury/cs/subtype.c subtype.m:036: Error: the first argument of `a' has a type, subtype.m:036: `list.list(subtype.phrasing_content_without_a)', which is not subtype.m:036: a subtype of the corresponding argument type subtype.m:036: `list.list(subtype.flow_content_without_a)' in the supertype. ** Error making `Mercury/cs/subtype.c'. | ||||
Steps To Reproduce | Run attached Mercury module with: mmc --make subtype | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | subtype.m (1,645) 2021-09-13 00:13 https://bugs.mercurylang.org/file_download.php?file_id=313&type=bug |
Notes | |||||
|
|||||
|
|
Issue History | |||||
Date Modified | Username | Field | Change | ||
---|---|---|---|---|---|
2021-09-13 00:13 | dirkz | New Issue | |||
2021-09-13 00:13 | dirkz | File Added: subtype.m | |||
2021-09-13 05:34 | zs | Assigned To | => zs | ||
2021-09-13 05:34 | zs | Status | new => resolved | ||
2021-09-13 05:34 | zs | Resolution | open => no change required | ||
2021-09-13 05:34 | zs | Note Added: 0001151 |