Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Be panicky about malformed traits

  • Loading branch information...
commit a540d4e994a0b41320bb1b7a11b8baa2ccb52e32 1 parent f87df17
Larry Wall TimToady authored

Showing 1 changed file with 8 additions and 6 deletions. Show diff stats Hide diff stats

  1. +8 6 STD.pm6
14 STD.pm6
@@ -1991,7 +1991,10 @@ grammar P6 is STD {
1991 1991 }
1992 1992
1993 1993 token trait_mod:is {
1994   - <sym>:s <longname><circumfix>? # e.g. context<rw> and Array[Int]
  1994 + <sym>:s [
  1995 + <longname><circumfix>? # e.g. context<rw> and Array[Int]
  1996 + || <.panic: "Invalid trait name">
  1997 + ]
1995 1998 {
1996 1999 if $*DECLARAND {
1997 2000 my $traitname = $<longname>.Str;
@@ -2001,22 +2004,21 @@ grammar P6 is STD {
2001 2004 }
2002 2005 }
2003 2006 token trait_mod:hides {
2004   - <sym>:s <typename>
  2007 + <sym>:s [<typename> || <.panic: "Invalid class name">]
2005 2008 }
2006 2009 token trait_mod:does {
2007 2010 :my $*PKGDECL ::= 'role';
2008   - <sym>:s <typename>
  2011 + <sym>:s [<typename> || <.panic: "Invalid role name">]
2009 2012 }
2010 2013 token trait_mod:will {
2011   - <sym>:s <identifier> <pblock>
  2014 + <sym>:s [<identifier> <pblock> || <.panic: "Invalid phaser">]
2012 2015 }
2013 2016
2014 2017 token trait_mod:of {
2015   - ['of'|'returns']:s <typename>
  2018 + ['of'|'returns']:s [<typename> || <.panic: "Invalid type name">]
2016 2019 [ <?{ $*DECLARAND<of> }> <.sorry("Extra 'of' type; already declared as type " ~ $*DECLARAND<of>.Str)> ]?
2017 2020 { $*DECLARAND<of> = $<typename>; }
2018 2021 }
2019   - token trait_mod:as { <sym>:s <typename> }
2020 2022 token trait_mod:handles { <sym>:s <term> }
2021 2023
2022 2024 #########

0 comments on commit a540d4e

Please sign in to comment.
Something went wrong with that request. Please try again.