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

Better errors for undefined #26

Closed
wayland opened this issue Oct 19, 2020 · 1 comment
Closed

Better errors for undefined #26

wayland opened this issue Oct 19, 2020 · 1 comment

Comments

@wayland
Copy link

wayland commented Oct 19, 2020

The error coming from the following would be more useful if it were to complain about the undefined value in some way; what I really want is a documented way to test if it's undefined like this. For the record, calling defined($!height) inside foo() also fails.

#!/usr/bin/raku

use     Physics::Unit;
use     Physics::Measure;

class   Test {
        has Length $.length;
        has Length $.width;

        method  foo {
                say $!length <=> $!width;
        }
}

my $a = Test.new();

$a.foo();

HTH,

@librasteve
Copy link
Owner

hi @wayland - I tried this... with no Physics::Unit or Physics::Measure...

#!/usr/bin/raku
##use Physics::Unit;
##use Physics::Measure;

class Test {
has Real $.length;
has Real $.width;
method foo {
say $!length &lt;=&gt; $!width;
}
}
my $a = Test.new();

$a.foo();

It gives this error:
Invocant of method 'Bridge' must be an object instance of type 'Real', not a type object of type 'Real'. Did you forget a '.new'?

So I am wondering whether is this a general raku issue - you are comparing 2 undefined objects after all.

I kinda prefer my error ...
Cannot look up attributes in a Physics::Measure::Length type object

What specifically would you propose?

~p6steve

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

2 participants