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

Ensure field unicity for records #286

Merged
merged 1 commit into from
Nov 7, 2016
Merged

Conversation

layus
Copy link
Member

@layus layus commented Oct 21, 2016

This patch checks that all the features of a record are distinct.

For the following example

declare A = a
{Browse abc(a:1 b:1 a:2 c:1 a:3)}             %1
thread {Browse abc(A:1 b:1 a:2 c:1 a:3)} end  %2
{Browse {Record.make abc [a b a c a]}}        %3

we get (separately)

### 1 ###
%********************** static analysis error *******************
%**
%** duplicate feature in record construction
%**
%** Features found: {a, b, a, c, a}
%** in file "Oz", line 3, column 16
%** ------------------ rejected (1 error)

### 2 ###
%********************* Error: duplicate fields ******************
%**
%** Duplicate fields in record construction
%**
%** Label:               abc
%** Feature-field Pairs: a#1 a#2 a#3 b#1 c#1
%**
%** Call Stack:
%** procedure 'Record.makeDynamic' in PC = 139701193282288
%** procedure in file "Oz", line 3, column 1, PC = 139701173938231
%**--------------------------------------------------------------

### 3 ###
%********************* Error: duplicate fields ******************
%**
%** Duplicate fields in record construction
%**
%** Label:               abc
%** Feature-field Pairs: a#_<optimized> a#_<optimized> a#_<optimized> b#_<optimized> c#_<optimized>
%**
%** Call Stack:
%** procedure 'Record.makeDynamic' in PC = 139701193282288
%** toplevel abstraction in line 1, column 0, PC = 139701294106019
%**--------------------------------------------------------------

I am still unhappy with the reordering that occurs in the error messages. I think th "Feature-field Pairs" should be printed in the order they were passed to Boot_record.makeDynamic, not the order resulting from the unstable std::sort.

With the first error, the static analyser catches the kernel error and prints the list of features in the correct order. Mozart1 used to return the unsorted features in all the cases.

That being said, I think this error code could be redesigned from scratch, and that the order of the features in the specific case of duplicate features is not really relevant. This is why I suggest to merge this patch.

@sjrd As usual, comments on C++ style are more than welcome.

Fixes #285

eregon added a commit to eregon/mozart-graal that referenced this pull request Oct 21, 2016
@sjmackenzie sjmackenzie merged commit 0c143af into mozart:master Nov 7, 2016
@layus layus deleted the checkArity branch October 24, 2017 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants