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

LTA error message when trying to use parens to declare enums (enum Animal (Cat, Dog)) #4902

Closed
p6rt opened this issue Dec 22, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Dec 22, 2015

Migrated from rt.perl.org#126987 (status was 'resolved')

Searchable as RT126987$

@p6rt
Copy link
Author

p6rt commented Dec 22, 2015

From @AlexDaniel

Code​:
enum Animal (Cat, Dog)

Result​:
===SORRY!===
Cannot invoke this object

Well, the error message is not so good, but you can say “who is going to do
that anyway?”. Well, consider this​:

Code​:
enum Animal (Cat => 25, Dog)

Result​:
===SORRY!===
Cannot invoke this object

Which is just a shorter version of this​:

Code​:
enum Animal (Cat => 25, Dog => 26)

Result​:
(no output, OK)

In which case you probably want to do this instead​:

Code​:
enum Bool «​:Cat(25) Dog»

Result​:
(no output, OK, Dog is actually 26)

Possible solution​:
If there is no way to see what is happening then just any better error
message than “Cannot invoke this object” (which does not even provide a
line number) will do.
If there is a way to see that the user actually wanted to use <> or «» then
it should suggest that.

@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

From @jnthn

On Tue Dec 22 05​:30​:41 2015, alex.jakimenko@​gmail.com wrote​:

Code​:
enum Animal (Cat, Dog)

Result​:
===SORRY!===
Cannot invoke this object

Well, the error message is not so good, but you can say “who is going to do
that anyway?”. Well, consider this​:

Code​:
enum Animal (Cat => 25, Dog)

Result​:
===SORRY!===
Cannot invoke this object

Which is just a shorter version of this​:

Code​:
enum Animal (Cat => 25, Dog => 26)

Result​:
(no output, OK)

In which case you probably want to do this instead​:

Code​:
enum Bool «​:Cat(25) Dog»

Result​:
(no output, OK, Dog is actually 26)

Possible solution​:
If there is no way to see what is happening then just any better error
message than “Cannot invoke this object” (which does not even provide a
line number) will do.
If there is a way to see that the user actually wanted to use <> or «» then
it should suggest that.

We now just report Cat and Dog as undeclared symbols, which makes clear that they were interpreted as lookups. This means they get a line number. Turns out that​:

constant foo = bar;

Did the same kind of blow-up (cannot invoke) rather than reporting bar undeclared; I've also fixed that.

Tests for both in S32-exceptions/misc.t.

@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

@jnthn - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant