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

Compiler: fix missing name_location of some calls #8192

Merged
merged 4 commits into from
Sep 16, 2019

Conversation

asterite
Copy link
Member

Fixes #8191

I think these were all the missing cases, but I'm not sure.

We have two choices:

  1. use location if name_location is missing: that way we'll never know if we missed setting a name_location somewhere
  2. just use name_location and crash if it's missing: bad for users, though they can still compile their code with --no-debug, but we'll know we are missing something and we can fix it

Probably 2 is better, so I didn't change anything else.

In any case, this line is smelly:

@call_location = call.name_location if call && call.location

it's strange that we check call.location to determine copying call.name_location. Shouldn't we check for name_location?

(though this seems to work, probably because location is set in more places than name_location)

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:debugger labels Sep 16, 2019
Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

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

We can change the smelly line probably to name_location in both cases.

I would've used the same resource as in playground spec to highlight the expected name location with a special character. But that's me that I don't like to count cols and lines.

@bew
Copy link
Contributor

bew commented Sep 16, 2019

What's the difference between location and name_location ?

@asterite
Copy link
Member Author

asterite commented Sep 16, 2019

@bew

foo.bar(1 + 2)
^   ^
|   |----- name_location
|
|--------- location

When an error says undefined method "bar" it will point and underline "bar" instead of somewhere at "foo". This is specially needed when "bar" appears in a different line:

foo.
  bar(1 + 2)

In the case of 1 + 2 I think the name_location will point to + instead of 1.

@bcardiff bcardiff added this to the 0.31.0 milestone Sep 16, 2019
@asterite asterite merged commit 390aa89 into crystal-lang:master Sep 16, 2019
@asterite asterite deleted the bug/missing-name-location branch September 16, 2019 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:debugger
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to compile a very basic HTTP server with --release flag
3 participants