Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 94585
Status: stalled
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: MITHALDU [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: useless error message on moose attribute when parent class constructor made an object not based on a hash reference
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-26230-1397086445-339.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 640
Download (untitled) / with headers
text/plain 640b
This error message: Not a HASH reference at (eval 188)[C:/Perl/lib/Eval/Closure.pm:125] line 9. Comes from this code: { package NonHashref; sub new { bless [], shift } } { package NonHashref::Subclassed; use Moose; extends "NonHashref"; has thing => ( is => 'rw', default => sub { 1 } ); } like exception { NonHashref::Subclassed->new->thing }, qr/Constructor of parent class of NonHashref::Subclassed returned an object based on ARRAY.*extends-non-moo/, 'non-hashref constructor in parent class results in useful error message'; Currently the same issue is being discussed in Moo: https://github.com/moose/Moo/pull/5
X-Sa-Exim-Connect-Ip: 69.50.167.197
MIME-Version: 1.0
X-Spam-Status: No, score=-2.588 tagged_above=-99.9 required=10 tests=[AWL=0.519, BAYES_00=-1.9, FROM_OUR_RT=-2, RDNS_NONE=0.793] autolearn=ham
In-Reply-To: <rt-4.0.18-26230-1397086445-646.94585-4-0 [...] rt.cpan.org>
Content-Disposition: inline
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-94585 [...] rt.cpan.org> <rt-4.0.18-26230-1397086445-646.94585-4-0 [...] rt.cpan.org>
X-Acl-Warn: !authenticated = *
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <20140409234124.GI26776 [...] tequila>
content-type: text/plain; charset="utf-8"
X-Spam-Score-Int: 0
X-RT-Original-Encoding: utf-8
X-Spam-Score: -2.588
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B592A240657 for <cpan-bug+Moose [...] hipster.bestpractical.com>; Wed, 9 Apr 2014 19:41:33 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gY0o-H30GGLD for <cpan-bug+Moose [...] hipster.bestpractical.com>; Wed, 9 Apr 2014 19:41:32 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 4ABA42403B1 for <bug-Moose [...] rt.cpan.org>; Wed, 9 Apr 2014 19:41:32 -0400 (EDT)
Received: (qmail 7560 invoked by alias); 9 Apr 2014 23:41:31 -0000
Received: from Unknown (HELO ns2.lightspeed.ca) (206.12.82.104) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 09 Apr 2014 16:41:29 -0700
Received: from 69-50-167-197.westerncable.ca ([69.50.167.197] helo=etheridge.ca) by ns2.lightspeed.ca with esmtp (Exim 4.72) (envelope-from <ether [...] cpan.org>) id 1WY27R-00032W-5p for bug-Moose [...] rt.cpan.org; Wed, 09 Apr 2014 16:41:25 -0700
Delivered-To: cpan-bug+Moose [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #94585] useless error message on moose attribute when parent class constructor made an object not based on a hash reference
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Sa-Exim-Mail-From: ether [...] cpan.org
Return-Path: <ether [...] cpan.org>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Moose [...] hipster.bestpractical.com
X-RT-Mail-Extension: moose
Date: Wed, 9 Apr 2014 16:41:24 -0700
X-Sa-Exim-Scanned: No (on ns2.lightspeed.ca); SAEximRunCond expanded to false
X-Spam-Level:
X-Spam-Bar: /
To: Christian Walde via RT <bug-Moose [...] rt.cpan.org>
Mail-Followup-To: Christian Walde via RT <bug-Moose [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
RT-Message-ID: <rt-4.0.18-23113-1397086894-34.94585-0-0 [...] rt.cpan.org>
Content-Length: 664
Download (untitled) / with headers
text/plain 664b
On Wed, Apr 09, 2014 at 07:34:06PM -0400, Christian Walde via RT wrote: Show quoted text
> This error message: > > Not a HASH reference at (eval 188)[C:/Perl/lib/Eval/Closure.pm:125] line 9. > > Comes from this code: > > { > package NonHashref; > sub new { bless [], shift } > } > { > package NonHashref::Subclassed; > use Moose; > extends "NonHashref"; > has thing => ( is => 'rw', default => sub { 1 } ); > }
This isn't valid code -- when extending a non-moose class, you need to use MooseX::NonMoose in the child. At that point, I think failure to handle non-hashref-based objects falls on MooseX::NonMoose to handle (or reject with a sensible error message).
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-23113-1397086894-34.94585-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-94585 [...] rt.cpan.org> <rt-4.0.18-26230-1397086445-646.94585-4-0 [...] rt.cpan.org> <20140409234124.GI26776 [...] tequila> <rt-4.0.18-23113-1397086894-34.94585-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-7661-1397087188-1220.94585-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 337
Download (untitled) / with headers
text/plain 337b
I do not care if the code can work or not, i know it cannot. It is code that can be reasonably expected to be written and has a useless error message. Further, if in fact it is an absolute requirement for Moose to use MooseX::NonMoose for non-Moose extension, then Moose currently still fails to check for this and inform the developer.
X-Sa-Exim-Connect-Ip: 69.50.167.197
MIME-Version: 1.0
X-Spam-Status: No, score=-2.599 tagged_above=-99.9 required=10 tests=[AWL=0.508, BAYES_00=-1.9, FROM_OUR_RT=-2, RDNS_NONE=0.793] autolearn=ham
In-Reply-To: <rt-4.0.18-7661-1397087188-1470.94585-5-0 [...] rt.cpan.org>
Content-Disposition: inline
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-94585 [...] rt.cpan.org> <rt-4.0.18-26230-1397086445-646.94585-4-0 [...] rt.cpan.org> <20140409234124.GI26776 [...] tequila> <rt-4.0.18-23113-1397086894-34.94585-5-0 [...] rt.cpan.org> <rt-4.0.18-7661-1397087188-1470.94585-5-0 [...] rt.cpan.org>
X-Acl-Warn: !authenticated = *
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <20140409235955.GJ26776 [...] tequila>
content-type: text/plain; charset="utf-8"
X-Spam-Score-Int: 0
X-RT-Original-Encoding: utf-8
X-Spam-Score: -2.599
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 20DDB240657 for <cpan-bug+Moose [...] hipster.bestpractical.com>; Wed, 9 Apr 2014 20:00:06 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nJA4RowMVS9o for <cpan-bug+Moose [...] hipster.bestpractical.com>; Wed, 9 Apr 2014 20:00:04 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 150AF2403B1 for <bug-Moose [...] rt.cpan.org>; Wed, 9 Apr 2014 20:00:03 -0400 (EDT)
Received: (qmail 8555 invoked by alias); 10 Apr 2014 00:00:00 -0000
Received: from Unknown (HELO ns2.lightspeed.ca) (206.12.82.104) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 09 Apr 2014 16:59:59 -0700
Received: from 69-50-167-197.westerncable.ca ([69.50.167.197] helo=etheridge.ca) by ns2.lightspeed.ca with esmtp (Exim 4.72) (envelope-from <ether [...] cpan.org>) id 1WY2PL-0003Um-Nk for bug-Moose [...] rt.cpan.org; Wed, 09 Apr 2014 16:59:55 -0700
Delivered-To: cpan-bug+Moose [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #94585] useless error message on moose attribute when parent class constructor made an object not based on a hash reference
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Sa-Exim-Mail-From: ether [...] cpan.org
Return-Path: <ether [...] cpan.org>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Moose [...] hipster.bestpractical.com
X-RT-Mail-Extension: moose
Date: Wed, 9 Apr 2014 16:59:55 -0700
X-Sa-Exim-Scanned: No (on ns2.lightspeed.ca); SAEximRunCond expanded to false
X-Spam-Level:
X-Spam-Bar: /
To: Christian Walde via RT <bug-Moose [...] rt.cpan.org>
Mail-Followup-To: Christian Walde via RT <bug-Moose [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
RT-Message-ID: <rt-4.0.18-26230-1397088007-1840.94585-0-0 [...] rt.cpan.org>
Content-Length: 615
Download (untitled) / with headers
text/plain 615b
On Wed, Apr 09, 2014 at 07:46:28PM -0400, Christian Walde via RT wrote: Show quoted text
> I do not care if the code can work or not, i know it cannot. It is code that can be reasonably expected to be written and has a useless error message. > Further, if in fact it is an absolute requirement for Moose to use MooseX::NonMoose for non-Moose extension, then Moose currently still fails to check for this and inform the developer.
I agree, the error message is not terribly enlightening. I suspect it's better for a non-Moose hashref-based object though, and that the arrayref part is interfering. But we can surely clean that up.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-26230-1397086445-339.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-26230-1397086445-339.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-1473-1407106089-1226.94585-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 515
Download (untitled) / with headers
text/plain 515b
I started looking into this and it's obvious how to fix it. Unlike Moo, we don't actually install a constructor in every class, so in the absence of immutabilization the only new() method that gets called is the one from the parent class. We can't inline the subclass constructor anyway, since it doesn't inherit from Moose::Object. The only place left to check for this sort of stuff is in the accessor methods themselves, but I don't think we want the overhead of checking the object's reftype on every access!
CC: ;
MIME-Version: 1.0
X-Spam-Status: No, score=-4.449 tagged_above=-99.9 required=10 tests=[AWL=0.009, BAYES_00=-1.9, DKIM_SIGNED=0.1, FROM_OUR_RT=-2, RP_MATCHES_RCVD=-0.668, T_DKIM_INVALID=0.01] autolearn=ham
In-Reply-To: <rt-4.0.18-1473-1407106089-1078.94585-5-0 [...] rt.cpan.org>
Content-Disposition: inline
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-94585 [...] rt.cpan.org> <rt-4.0.18-26230-1397086445-339.94585-5-0 [...] rt.cpan.org> <rt-4.0.18-1473-1407106089-1078.94585-5-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <20140803230510.GA20061 [...] lance>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -4.449
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=softfail (invalid, public key: does not support hash algorithm 'sha256') header.i= [...] tozt.net
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id A33FB240203 for <cpan-bug+Moose [...] hipster.bestpractical.com>; Sun, 3 Aug 2014 19:05:24 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zzok4JjVhY+F for <cpan-bug+Moose [...] hipster.bestpractical.com>; Sun, 3 Aug 2014 19:05:23 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 5E224240039 for <bug-Moose [...] rt.cpan.org>; Sun, 3 Aug 2014 19:05:23 -0400 (EDT)
Received: (qmail 17518 invoked by alias); 3 Aug 2014 23:05:22 -0000
Received: from tozt.net (HELO mail.tozt.net) (162.216.19.228) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sun, 03 Aug 2014 16:05:20 -0700
Received: from localhost (pool-96-253-38-176.prvdri.fios.verizon.net [96.253.38.176]) by mail.tozt.net (Postfix) with ESMTPSA id B2A48427FA for <bug-Moose [...] rt.cpan.org>; Sun, 3 Aug 2014 19:05:16 -0400 (EDT)
Delivered-To: cpan-bug+Moose [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #94585] useless error message on moose attribute when parent class constructor made an object not based on a hash reference
User-Agent: Mutt/1.5.23 (2014-03-12)
Return-Path: <doy [...] tozt.net>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tozt.net; s=mail; t=1407107116; bh=d3Yq8RHhBupoZtowngcVKqI5WmPD2g+m+P681i66YUQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=lslUG+KPvoBRLR9CHU371txNC/Cve6TJT+eQq2hczUtHDNUD4R7WaZAqpDH8k4alO xQMzVIsyXmooAArLOb65iJekONmZv59rTMhjLbLDD5DGqxej+CYfH79B6RB2oiDz7W gb65W7+kEEHsNbFVpES+tg6UPuxhklb2eHC5e8YM=
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Moose [...] hipster.bestpractical.com
X-RT-Mail-Extension: moose
Date: Sun, 3 Aug 2014 19:05:10 -0400
X-Spam-Level:
To: Dave Rolsky via RT <bug-Moose [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
RT-Message-ID: <rt-4.0.18-14118-1407107125-802.94585-0-0 [...] rt.cpan.org>
Content-Length: 332
Download (untitled) / with headers
text/plain 332b
For what it's worth, it's absolutely not a requirement to use MooseX::NonMoose when extending a non-Moose class. There is quite a bit of code in the wild that relies on this (it was always the case that Moose was written to be used with existing code, but MooseX::NonMoose wasn't written for quite some time after Moose was). -doy


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.