google-code-export / umple

Automatically exported from code.google.com/p/umple
1 stars 0 forks source link

Sorted associations in certain cases give misleading error message mentioning wrong class #361

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Compile the following code

class Academy {
  1 -- * Course sorted {code};
   }
}

class Student {
  Integer id;
  name;
}

class Course {
  code;
}

class Registration {
  * sorted {id}-- 1 Student;
  * sorted {code} -- 1 Course;
}

association {
  1 Academy -- * Student registrants sorted {id};
}

What is the expected output? What do you see instead?

The following errors are encountered:
Error on line 30 of file "m.ump":
Class 'Student' does not contain variable id
Error on line 31 of file "m.ump":
Class 'Course' does not contain variable code

Both messages should say Class 'Registration' does not contain ...

The sorted feature of Umple associations was added in issue 184
The feature mostly work but this bug needs fixing.
This is presumably just a minor issue in the parser.

Original issue reported on code.google.com by TimothyCLethbridge on 3 Jan 2013 at 3:00

GoogleCodeExporter commented 9 years ago
Here's another test case, with one correct and one incorrect message:

// This example generates the error message
class X {
  1 -- * Y sorted {nom};
    * sorted {efd} -- 1 Y;
}

class Y {
  name;
}

Original comment by TimothyCLethbridge on 6 Jan 2013 at 9:42

GoogleCodeExporter commented 9 years ago
I take back my last comment. They are both wrong -- just opposite directions.

Original comment by TimothyCLethbridge on 6 Jan 2013 at 9:43

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I believe this is actually a problem with the error message, it should read:
The following errors are encountered:
Error on line 30 of file "m.ump":
Class 'Registration' does not contain variable id
Error on line 31 of file "m.ump":
Class 'Registration' does not contain variable code
(because Reigstration doesn't)

To resolve the code change:
* sorted {id}-- 1 Student;
  * sorted {code} -- 1 Course;
to
* -- 1 Student sorted {id};
* -- 1 Course sorted {id};

Original comment by RedEyedM...@gmail.com on 7 Jan 2013 at 12:44

GoogleCodeExporter commented 9 years ago
Yes, the error messages are backwards. Take the following code. I have 
commented out the two derived attributes. If you uncomment those attributes it 
works. The error messages need to be switched so they refer to the correct 
classes in all cases.

class Academy {
  1 -- * Course sorted {code};
}

class Student {
  Integer id;
  name;
  1 -- * Registration sorted {name};
}

class Course {
  code;
  1 -- * Registration sorted {code};
}

class Registration {
  // code = {getStudent().getCode();}
  // name = {getStudent().getName();}
}

association {
  1 Academy -- * Student registrants sorted {id};
}

Original comment by TimothyCLethbridge on 8 Jan 2013 at 9:57

GoogleCodeExporter commented 9 years ago
no test cases for this one because it was an error message at fault.

Original comment by RedEyedM...@gmail.com on 9 Jan 2013 at 12:11

Attachments:

GoogleCodeExporter commented 9 years ago
fixed a of r2378

Original comment by TimothyCLethbridge on 9 Jan 2013 at 2:08