ETSI's Bug Tracker - Part 01: TTCN-3 Core Language
View Issue Details

ID | Project | Category | View Status | Date Submitted | Last Update
0007672 | Part 01: TTCN-3 Core Language | Technical | public | 03-05-2017 11:00 | 05-01-2018 09:55

Reporter | Tomas Urban |
Assigned To | Gyorgy Rethy |
Priority | normal | Severity | minor | Reproducibility | have not tried
Status | closed | Resolution | fixed |
Platform |  | OS |  | OS Version |
Product Version | v4.9.1 (published 2017-05) |
Target Version | v4.10.1 (published 2018-05) | Fixed in Version | v4.10.1 (published 2018-05) |
Clause Reference(s) | 6.3.2.1
Source (company - Author) | Elvior

Summary | 0007672: Compatibility of enumerated types

Description

The new rules on compatibility of enumerated types are based on individual enumerated values which means that types are sometimes compatible and sometimes not. That makes static semantic analysis quite difficult and leads to runtime errors.
Example:
type enumerated EWorkDays { Mon, Tue, Wed, Thu, Fri }
type enumerated EWeekDays { Mon, Tue, Wed, Thu, Fri, Sat, Sun }
...
var EWorkDays v_workDay := Mon;
var EWeekDays v_weekDay := Mon;
log (v_workDay == v_weekDay); // ok, logs "true"
v_weekDay := Sat;
log (v_workDay == v_weekDay); // leads to type compatibility error
Proposal:
1. Add an additional rule to the relation operations that would produce false in case of comparing non-compatible values of partially compatible enumerations as in the example above.
2. Describe in detail the assignment process with all possible errors and create examples (v_weekDay := v_workDay should be always possible, v_workDay := v_weekDay could work, but it can produce runtime errors too).

Steps To Reproduce |
Additional Information |
Tags | No tags attached.
Relationships |

Attached Files

7672.doc (15,360) 24-07-2017 07:36
http://oldforge.etsi.org/mantis/file_download.php?file_id=3646&type=bug
7672_2.doc (16,896) 25-07-2017 10:59
http://oldforge.etsi.org/mantis/file_download.php?file_id=3651&type=bug
7672_3.doc (31,232) 26-10-2017 11:40
http://oldforge.etsi.org/mantis/file_download.php?file_id=3711&type=bug
7672_4.doc (32,256) 26-10-2017 14:46
http://oldforge.etsi.org/mantis/file_download.php?file_id=3716&type=bug
CR7276_5.docx (74,327) 04-01-2018 11:36
http://oldforge.etsi.org/mantis/file_download.php?file_id=3733&type=bug

Issue History
Date Modified | Username | Field | Change
03-05-2017 11:00 | Tomas Urban | New Issue |
03-05-2017 11:12 | Jacob Wieland - Spirent | Note Added: 0014614 |
06-06-2017 11:23 | Jens Grabowski | Assigned To | => Julien Deltour
06-06-2017 11:23 | Jens Grabowski | Status | new => assigned
07-06-2017 08:45 | szabados | Note Added: 0014636 |
24-07-2017 07:36 | Julien Deltour | File Added: 7672.doc |
24-07-2017 07:36 | Julien Deltour | Note Added: 0014730 |
24-07-2017 07:37 | Julien Deltour | Status | assigned => confirmed
24-07-2017 07:37 | Julien Deltour | Assigned To | Julien Deltour => Tomas Urban
24-07-2017 07:37 | Julien Deltour | Status | confirmed => assigned
24-07-2017 10:33 | Jacob Wieland - Spirent | Note Added: 0014731 |
24-07-2017 16:18 | Tomas Urban | Assigned To | Tomas Urban => Julien Deltour
25-07-2017 10:59 | Julien Deltour | File Added: 7672_2.doc |
25-07-2017 11:00 | Julien Deltour | Note Added: 0014749 |
25-07-2017 11:00 | Julien Deltour | Assigned To | Julien Deltour => Jacob Wieland - Spirent
25-07-2017 11:00 | Julien Deltour | Status | assigned => confirmed
25-07-2017 16:32 | KristÃ³f Szabados | Note Added: 0014760 |
25-07-2017 16:33 | KristÃ³f Szabados | Note Deleted: 0014760 |
26-07-2017 09:01 | Jacob Wieland - Spirent | Note Added: 0014770 |
26-07-2017 09:02 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Julien Deltour
26-07-2017 09:02 | Jacob Wieland - Spirent | Status | confirmed => assigned
26-10-2017 11:40 | Julien Deltour | File Added: 7672_3.doc |
26-10-2017 11:40 | Julien Deltour | Note Added: 0014886 |
26-10-2017 11:41 | Julien Deltour | Status | assigned => confirmed
26-10-2017 11:41 | Julien Deltour | Assigned To | Julien Deltour => Jacob Wieland - Spirent
26-10-2017 11:41 | Julien Deltour | Status | confirmed => assigned
26-10-2017 14:46 | Jacob Wieland - Spirent | Note Added: 0014897 |
26-10-2017 14:46 | Jacob Wieland - Spirent | File Added: 7672_4.doc |
26-10-2017 14:47 | Jacob Wieland - Spirent | Note Added: 0014898 |
26-10-2017 14:47 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Jens Grabowski
26-10-2017 14:47 | Jacob Wieland - Spirent | Status | assigned => confirmed
02-01-2018 13:32 | Jens Grabowski | Note Added: 0014986 |
02-01-2018 13:32 | Jens Grabowski | Note Added: 0014987 |
02-01-2018 13:32 | Jens Grabowski | Status | confirmed => resolved
02-01-2018 13:32 | Jens Grabowski | Resolution | open => fixed
02-01-2018 13:32 | Jens Grabowski | Assigned To | Jens Grabowski => Gyorgy Rethy
04-01-2018 11:36 | Gyorgy Rethy | Note Added: 0014992 |
04-01-2018 11:36 | Gyorgy Rethy | File Added: CR7276_5.docx |
04-01-2018 11:37 | Gyorgy Rethy | Assigned To | Gyorgy Rethy => Jens Grabowski
04-01-2018 11:37 | Gyorgy Rethy | Status | resolved => confirmed
04-01-2018 11:38 | Gyorgy Rethy | Note Edited: 0014992 | bug_revision_view_page.php?bugnote_id=14992#r454
04-01-2018 11:40 | Gyorgy Rethy | Note Edited: 0014992 | bug_revision_view_page.php?bugnote_id=14992#r455
04-01-2018 11:40 | Gyorgy Rethy | Note Edited: 0014992 | bug_revision_view_page.php?bugnote_id=14992#r456
04-01-2018 11:41 | Gyorgy Rethy | Note Edited: 0014992 | bug_revision_view_page.php?bugnote_id=14992#r457
04-01-2018 11:51 | Gyorgy Rethy | Target Version | => v4.10.1 (published 2018-05)
05-01-2018 09:08 | Jens Grabowski | Note Added: 0014998 |
05-01-2018 09:08 | Jens Grabowski | Status | confirmed => resolved
05-01-2018 09:08 | Jens Grabowski | Assigned To | Jens Grabowski => Gyorgy Rethy
05-01-2018 09:46 | Gyorgy Rethy | Note Edited: 0014992 | bug_revision_view_page.php?bugnote_id=14992#r458
05-01-2018 09:55 | Gyorgy Rethy | Note Added: 0015003 |
05-01-2018 09:55 | Gyorgy Rethy | Status | resolved => closed
05-01-2018 09:55 | Gyorgy Rethy | Fixed in Version | => v4.10.1 (published 2018-05)

Notes

(0014614)
Jacob Wieland - Spirent
03-05-2017 11:12

It should behave the same way as for restricted integer types.
type integer I1 (1 .. 10);
type integer I2 (5 .. 50);
var I1 v_1 := 5;
var I2 v_2 := 5;
log(v_1 == v2); // should produce true
v_1 := 1;
log(v_1 == v_2);// should produce false
Basically, the comparison should work on the least-upper-bound of the two enumerated types, i.e. an (imaginary) enumerated type that contains all named values from both involved enumerated types. If they are not compatible, there is no least-upper-bound.
This is the same principle as for the integer-comparison, here, the base type (which is an upper bound of all integer types) is used for the actual comparison semantics.

(0014636)
szabados
07-06-2017 08:45

I believe, that this understanding would require some examples in standard.
example1:
2 enums compatible if the only difference is that in one of them has the numbers explicitly set, the other not.
"
type enumerated EWeekDays2 { Mon(0), Tue(1), Wed(2), Thu(3), Fri(4), Sat(5), Sun(6) }
var EWeekDays2 v_weekDay2 := Mon;
log (v_weekDay == v_weekDay2); // ok, logs "true"
"
example2:
2 enums that contain the same value and have the same semantic meaning are not compatible if the values are listed in a different order.
"
type enumerated EWeekDaysReordered { Sun, Mon, Tue, Wed, Thu, Fri, Sat }
var EWeekDaysReordered v_weekDayReordered := Mon;
log (v_weekDay == EWeekDaysReordered); // ok, logs "false"
"

(0014730)
Julien Deltour
24-07-2017 07:36

Please review

(0014731)
Jacob Wieland - Spirent
24-07-2017 10:33

while the examples are very good, the description why comparing two enumerated types who are only partly (or not at all) compatible leads to false is somehow missing in the description text.

(0014749)
Julien Deltour
25-07-2017 11:00

The description of why two partially compatible enumerated types can return false has been added. Can you please review.

(0014770)
Jacob Wieland - Spirent
26-07-2017 09:01

I have not found it. Also, I would expect this description in the definition of the equality operator, not in the type compatibility section.
The description should define that values of two enumerated types which can be combined to a larger enumerated type by merging their members together can be compared and will lead to true if the value with the same number associated exists in both enumerated types is the same on both sides of the equality operator, otherwise, the expression will evaluate to false.
Thus, equality can only produce an error if the two types cannot be merged,i.e. if a number value is associated with two different names after the merging process.

(0014886)
Julien Deltour
26-10-2017 11:40

Please can you check for this new proposal ?

(0014897)
Jacob Wieland - Spirent
26-10-2017 14:46

I have reworded it slightly and in a way that is consistent with the proposal that two enumerated entities can only be compared if their types are mergeable. Otherwise, it is a static error.
I have removed the assignment part as that has nothing to do with the mergeability of the enumerated types, but only with the simple compatibility rule. (a can be assigned to var of type B if a is compatible to B)
The comparison examples should probably be moved to the section defining the comparison operators.

(0014898)
Jacob Wieland - Spirent
26-10-2017 14:47

please check as well

(0014986)
Jens Grabowski
02-01-2018 13:32

Ok

(0014987)
Jens Grabowski
02-01-2018 13:32

György, please have a final check.

(0014992)
Gyorgy Rethy
04-01-2018 11:36 (edited on: 05-01-2018 09:46)

Example 2 is showing cases of compatible/incompatible assignments. This is OK.
But the new text and example 1 are related to comparing enum. values, which is described in clause 7.1.3 Relational operators. Now, the new text 6.3.2.1 and the current text in 7.1.3 are contradicting. In 7.1.3: "The relational operators less than (<), greater than (>), greater than or equal to (>=), and less than or equal to (<=) shall have only operands... or instances of the same enumerated type. It is not allowed to compare instances of different root types.
...
Operands of equality (==) and non-equality (!=) shall be ... of type compatible root types ..."
New text in the CR allows comparing values of different, non-compatible enumerated types, while current 7.1.3 text forbids this. So, I propose to replace the current rule in 7.1.3 with the new one in this CR.
See my resolution text proposal in CR7672_5.doc

(0014998)
Jens Grabowski
05-01-2018 09:08

Yes, looks good.

(0015003)
Gyorgy Rethy
05-01-2018 09:55

Implemented in draft V4.9.3.