Skip to content

Commit 53b3ca6

Browse files
committed
clean up misleading P5 special var warnings
Remove the tests for rare variables, especially those that will become syntax errors anyway, like $) and friends. This also allows us to parse bare sigils as rvalues, so we don't have to distinguish ($a,*,$c) = ... from my ($a,$,$c) = ... anymore. That is, if you use a bare $ as an rvalue, we'll simply declare an anonymous variable for you now. If we make the declarator default to 'state', it might even be useful as $++.
1 parent ee1ef48 commit 53b3ca6

File tree

1 file changed

+13
-56
lines changed

1 file changed

+13
-56
lines changed

STD.pm6

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,13 +2199,13 @@ grammar P6 is STD {
21992199
}
22002200

22012201
token special_variable:sym<$~> {
2202-
<sym> <!before \w | '('>
2202+
<sym> <?before \h* '='>
22032203
<.obs('$~ variable', 'Form module')>
22042204
}
22052205

22062206
token special_variable:sym<$`> {
22072207
<sym>
2208-
<.obs('$` variable', 'explicit pattern before <(')>
2208+
<.obs('$` variable', '$/.prematch')>
22092209
}
22102210

22112211
token special_variable:sym<$@> {
@@ -2225,7 +2225,7 @@ grammar P6 is STD {
22252225
<.obs('$$ variable', '$*PID')>
22262226
}
22272227
token special_variable:sym<$%> {
2228-
<sym> <!before \w | '(' | <sigil> >
2228+
<sym> <?before \h* '='>
22292229
<.obs('$% variable', 'Form module')>
22302230
}
22312231

@@ -2236,7 +2236,7 @@ grammar P6 is STD {
22362236
}
22372237

22382238
token special_variable:sym<$^> {
2239-
<sym> <!before \w>
2239+
<sym> <?before \h* '='>
22402240
<.obs('$^ variable', 'Form module')>
22412241
}
22422242

@@ -2246,22 +2246,12 @@ grammar P6 is STD {
22462246
}
22472247

22482248
token special_variable:sym<$*> {
2249-
<sym> <!before \w | '(' >
2249+
<sym> <?before \h* '='>
22502250
<.obs('$* variable', '^^ and $$')>
22512251
}
22522252

2253-
token special_variable:sym<$)> {
2254-
<sym> <?{ $*GOAL ne ')' }>
2255-
<.obs('$) variable', '$*EGID')>
2256-
}
2257-
2258-
token special_variable:sym<$-> {
2259-
<sym> <!{ $*IN_DECL }>
2260-
<.obs('$- variable', 'Form module')>
2261-
}
2262-
22632253
token special_variable:sym<$=> {
2264-
<sym> <!before \w | '('> <!{ $*IN_DECL }>
2254+
<sym> <?before \h+ '='>
22652255
<.obs('$= variable', 'Form module')>
22662256
}
22672257

@@ -2315,11 +2305,6 @@ grammar P6 is STD {
23152305
<.obs('%- variable', '.from method')>
23162306
}
23172307

2318-
token special_variable:sym<$+> {
2319-
<sym> :: <?before \s | ',' | <terminator> > <!{ $*IN_DECL }>
2320-
<.obs('$+ variable', 'Form module')>
2321-
}
2322-
23232308
token special_variable:sym<${^ }> {
23242309
<sigil> '{^' :: $<text>=[.*?] '}'
23252310
<.obscaret($<sigil>.Str ~ '{^' ~ $<text>.Str ~ '}', $<sigil>.Str, $<text>.Str)>
@@ -2393,61 +2378,41 @@ grammar P6 is STD {
23932378
} # always fails, don't need curlycheck here
23942379
}
23952380

2396-
token special_variable:sym<$[> {
2397-
<sym> <!{ $*IN_DECL }>
2398-
<.obs('$[ variable', 'user-defined array indices')>
2399-
}
2400-
2401-
token special_variable:sym<$]> {
2402-
<sym>
2403-
<.obs('$] variable', '$*PERL_VERSION')>
2404-
}
2405-
24062381
token special_variable:sym<$\\> {
24072382
<sym> <!{ $*IN_DECL }>
24082383
<.obs('$\\ variable', "the filehandle's :ors attribute")>
24092384
}
24102385

24112386
token special_variable:sym<$|> {
2412-
<sym>
2387+
<sym> <?before \h* '='>
24132388
<.obs('$| variable', ':autoflush on open')>
24142389
}
24152390

24162391
token special_variable:sym<$:> {
2417-
<sym> <!before \w>
2392+
<sym> <?before \h* '='>
24182393
<.obs('$: variable', 'Form module')>
24192394
}
24202395

24212396
token special_variable:sym<$;> {
2422-
<sym> <!{ $*IN_DECL }>
2397+
<sym> <?before \h* '='>
24232398
<.obs('$; variable', 'real multidimensional hashes')>
24242399
}
24252400

24262401
token special_variable:sym<$'> { #'
24272402
<sym> <!{ $*QSIGIL }>
2428-
<.obs('$' ~ "'" ~ 'variable', "explicit pattern after )\x3E")>
2403+
<.obs('$' ~ "'" ~ ' variable', '$/.postmatch')>
24292404
}
24302405

24312406
token special_variable:sym<$"> {
2432-
<sym> <!{ $*QSIGIL }>
2407+
<sym> <?before \h* '='>
24332408
<.obs('$" variable', '.join() method')>
24342409
}
24352410

24362411
token special_variable:sym<$,> {
2437-
<sym> <?before \h* <[ = , ; ? : ! ) \] } ]> >
2412+
<sym> <?before \h* '='>
24382413
<.obs('$, variable', ".join() method")>
24392414
}
24402415

2441-
token special_variable:sym['$<'] {
2442-
<sym> <?before \h* <[ = , ; ? : ! ) \] } ]> <!before \S* '>'> >
2443-
<.obs('$< variable', '$*UID')>
2444-
}
2445-
2446-
token special_variable:sym«\$>» {
2447-
<sym>
2448-
<.obs('$> variable', '$*EUID')>
2449-
}
2450-
24512416
token special_variable:sym<$.> {
24522417
<sym> <!before \w | '('>
24532418
<.obs('$. variable', "the filehandle's .line method")>
@@ -2498,15 +2463,7 @@ grammar P6 is STD {
24982463
# Note: $() can also parse as contextualizer in an expression; should have same effect
24992464
| <sigil> <?before '<'> <postcircumfix> [<?{ $*IN_DECL }> <.panic: "Cannot declare a match variable">]?
25002465
| :dba('contextualizer') <sigil> '(' ~ ')' <semilist> { $*LEFTSIGIL ||= $<sigil>.Str } <O(|%term)> [<?{ $*IN_DECL }> <.panic: "Cannot declare a contextualizer">]?
2501-
| <sigil> <?{ $*IN_DECL }>
2502-
| <?> {
2503-
if $*QSIGIL {
2504-
return ();
2505-
}
2506-
else {
2507-
.sorry("Non-declarative sigil is missing its name");
2508-
}
2509-
}
2466+
| <sigil>
25102467
]
25112468
]
25122469

0 commit comments

Comments
 (0)