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

Detect overlapping field names #147

Merged
merged 2 commits into from
Jun 10, 2020
Merged

Conversation

ltratt
Copy link
Member

@ltratt ltratt commented Jun 9, 2020

There are two cases to be dealt with:

  1. A field name has already been defined in a superclass (5e00d91).
  2. A class defines the same field more than once (9370609).

The first of those was pointed out by @Hirevo in SOM-st/SOM#42; the second is a relatively simple variation on the same theme.

stderr:
...test.som', line 10, column 23:
test = test_super ( | a |
Field 'a' is already defined in a superclass.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this should be "Field" or (as below) "Field name". Any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I as non-native speak would say: 'Field a is already defined' or 'A field with the name a is already defined'.
"Field name 'a' has already been defined in this class." feels wrong.
Perhaps 'A field named 'a' ...' as another option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think on reflection that "Field" is better than "Field name" (due to the fields method being a precedent).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f57c74b.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better "A field by the name 'a' is already defined...".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most useful improvement would IMHO be to name the superclass and the source location where the conflicting field is defined. That would be very developer-friendly :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think error messages need to use full grammar (so to speak): it can often end up being pointless extra verbiage to plough through especially when you tend to see the same messages over and over again. I think I'd prefer to keep it as in f57c74b.

stderr:
...test.som', line 10, column 23:
test = test_super ( | a |
Field 'a' is already defined in a superclass.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I as non-native speak would say: 'Field a is already defined' or 'A field with the name a is already defined'.
"Field name 'a' has already been defined in this class." feels wrong.
Perhaps 'A field named 'a' ...' as another option.

stderr:
...instance_fields_overlap2.som', line 11, column 9:
| a a |
Field name 'a' has already been defined in this class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I am surprised by is that you don't format the error message in a "standard way" with path:line:column, which is supported by a large number of tools for navigation to the error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that's a standard to be honest! Changing the formatting is pretty trivial if anyone wants to raise a PR for it (it's not something I feel very strongly about either way), with the only proviso that I think the console output should still look reasonable for humans.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a standard, just a defacto thing a lot of tools support.
Not to insult anyone, but if I remember correctly, you're using vim.
In vim, for instance with :make you get :cnext etc to navigate to errors.

That's simply taking the test.c:4:3: error: use of undeclared identifier 'bax' message to work.
In many IDEs, these lines are recognized and clickable to jump to errors.

So, all I am saying it may even make your own life easier :)

@vext01
Copy link
Member

vext01 commented Jun 10, 2020

A handful of comments.

@ltratt
Copy link
Member Author

ltratt commented Jun 10, 2020

I tend to agree with @smarr that this PR isn't about duplicate superclasses (SOM doesn't have the diamond problem).

@vext01
Copy link
Member

vext01 commented Jun 10, 2020

Agreed.

I think I'm happy with this. Shall I merge?

@vext01
Copy link
Member

vext01 commented Jun 10, 2020

Ah, please squash first.

@ltratt
Copy link
Member Author

ltratt commented Jun 10, 2020

I need to squash if that's OK?

@ltratt
Copy link
Member Author

ltratt commented Jun 10, 2020

Squashed.

@ltratt ltratt force-pushed the overlapping_fields branch from 735b752 to 4d6ba76 Compare June 10, 2020 10:58
@vext01
Copy link
Member

vext01 commented Jun 10, 2020

bors r+

@vext01
Copy link
Member

vext01 commented Jun 10, 2020

I realise that some of my comments from earlier didn't make a great deal of sense. Maybe another coffee before my next PR review! My bad.

@ltratt
Copy link
Member Author

ltratt commented Jun 10, 2020

It's not your fault -- I don't expect you to know SOM inside out (I'm only starting to slowly get to grips with it myself!).

@bors
Copy link
Contributor

bors bot commented Jun 10, 2020

Build succeeded:

@bors bors bot merged commit 48f10d9 into softdevteam:master Jun 10, 2020
@ltratt ltratt deleted the overlapping_fields branch June 10, 2020 12:10
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.

3 participants