Tweaks for coercions
[gitmo/Mouse.git] / xs-src / MouseAttribute.xs
index 4086d2b..7a453fd 100644 (file)
@@ -184,6 +184,7 @@ mouse_xa_set_default(pTHX_ AV* const xa, SV* const object) {
     return value;
 }
 
+/* checks $isa->does($does) */
 static void
 mouse_check_isa_does_does(pTHX_ SV* const klass, SV* const name, SV* const isa, SV* const does){
     STRLEN len;
@@ -271,6 +272,7 @@ void
 _process_options(SV* klass, SV* name, HV* args)
 CODE:
 {
+    /* TODO: initialize 'xa' here */
     SV** svp;
     SV* tc = NULL;
 
@@ -337,7 +339,9 @@ CODE:
             else{
                 svp = hv_fetchs(args, "accessor", TRUE);
             }
-            sv_setsv(*svp, name);
+            if(!SvOK(*svp)) {
+                sv_setsv(*svp, name);
+            }
         }
         else if(strEQ(is, "bare")){
             /* do nothing, but might complain later about missing methods */
@@ -472,7 +476,7 @@ CODE:
     if(svp && sv_true(*svp)){
         if(!(has_default || has_builder)){
             mouse_throw_error(klass, NULL,
-                "You cannot have lazy attribute (%"SVf") without specifying "
+                "You cannot have a lazy attribute (%"SVf") without specifying "
                 "a default value for it", name);
         }
     }