20.06.15

New changes to make SpiderMonkey’s (and Firefox’s) parsing of destructuring patterns more spec-compliant

Destructuring in JavaScript

One new feature in JavaScript, introduced in ECMAScript 6 (formally ECMAScript 2015, but it’ll always be ES6 in our hearts), is destructuring. Destructuring is syntactic sugar for assigning sub-values within a single value — nested properties, iteration results, &c., to arbitrary depths — to a set of locations (names, properties, &c.).

// Declarations
var [a, b] = [1, 2]; // a = 1, b = 2
var { x: c, y: d } = { x: 42, y: 17 }; // c = 42, d = 17

function f([z]) { return z; }
print(f([8675309])); // 8675309


// Assignments
[b, f.prop] = [3, 15]; // b = 3, f.prop = 15
({ p: d } = { p: 33 }); // d = 33

function Point(x, y) { this.x = x; this.y = y; }

// Nesting's copacetic, too.
// a = 2, b = 4, c = 8, d = 16
[{ x: a, y: b }, [c, d]] = [new Point(2, 4), [8, 16]];

Ambiguities in the parsing of destructuring

One wrinkle to destructuring is its ambiguity: reading start to finish, is a “destructuring pattern” instead a literal? Until any succeeding = is observed, it’s impossible to know. And for object destructuring patterns, could the “pattern” just be a block statement? (A block statement is a list of statements inside {}, e.g. many loop bodies.)

How ES6 handles the potential parser ambiguities in destructuring

ES6 says an apparent “pattern” could be any of these possibilities: the only way to know is to completely parse the expression/statement. There are more elegant and less elegant ways to do this, although in the end they amount to the same thing.

Object destructuring patterns present somewhat less ambiguity than array patterns. In expression context, { may begin an object literal or an object destructuring pattern (just as [ does for arrays, mutatis mutandis). But in statement context, { since the dawn of JavaScript only begins a block statement, never an object literal — and now, never an object destructuring pattern.

How then to write object destructuring pattern assignments not in expression context? For some time SpiderMonkey has allowed destructuring patterns to be parenthesized, incidentally eliminating this ambiguity. But ES6 chose another path. In ES6 destructuring patterns must not be parenthesized, at any level of nesting within the pattern. And in declarative destructuring patterns (but not in destructuring assignments), declaration names also must not be parenthesized.

SpiderMonkey now adheres to ES6 in requiring no parentheses around destructuring patterns

As of several hours ago on mozilla-inbound, SpiderMonkey conforms to ES6’s parsing requirements for destructuring, with respect to parenthesization. These examples are all now syntax errors:

// Declarations
var [(a)] = [1]; // BAD, a parenthesized
var { x: (c) } = {}; // BAD, c parenthesized
var { o: ({ p: p }) } = { o: { p: 2 } }; // BAD, nested pattern parenthesized

function f([(z)]) { return z; } // BAD, z parenthesized

// Top level
({ p: a }) = { p: 42 }; // BAD, pattern parenthesized
([a]) = [5]; // BAD, pattern parenthesized

// Nested
[({ p: a }), { x: c }] = [{}, {}]; // BAD, nested pattern parenthesized

Non-array/object patterns in destructuring assignments, outside of declarations, can still be parenthesized:

// Assignments
[(b)] = [3]; // OK: parentheses allowed around non-pattern in a non-declaration assignment
({ p: (d) } = {}); // OK: ditto
[(parseInt.prop)] = [3]; // OK: parseInt.prop not a pattern, assigns parseInt.prop = 3

Conclusion

These changes shouldn’t much disrupt anyone writing JS. Parentheses around array patterns are unnecessary and are easily removed. For object patterns, instead of parenthesizing the object pattern, parenthesize the whole assignment. No big deal!

// Assignments
([b]) = [3]; // BAD: parentheses around array pattern
[b] = [3]; // GOOD

({ p: d }) = { p: 2 }; // BAD: parentheses around object pattern
({ p: d } = { p: 2 }); // GOOD

One step forward for SpiderMonkey standards compliance!

16.06.15

San Francisco v. Sheehan: opinion and analysis

Last time I gave my last pre-opinion thoughts on the Texas specialty license plate case, Walker v. Texas Division, Sons of Confederate Veterans, whose oral argument I attended in March. The other case I saw that day, San Francisco v. Sheehan, was recently decided. Today I discuss the opinions in that case.

Ninth Circuit overturned, film at 11

My dismissive suggestion that San Francisco would win because Ninth Circuit and qualified immunity was on target. The Court ruled, 6-2, that the officers should receive qualified immunity — giving the win to San Francisco.

The Americans with Disabilities Act and accommodating the disabled

Recall that Justice Scalia and others alleged that San Francisco had improperly changed its argument from the time it got the Supreme Court to hear the case, to when it presented its formal argument. San Francisco initially argued that the Americans with Disabilities Act categorically didn’t require officers to accommodate armed and violent suspects who are disabled. But then later it argued that the ADA didn’t apply specifically to Sheehan, because she had posed a “direct threat”.

Every justice agreed that San Francisco’s tactics precluded the Court from deciding whether the ADA applied to armed and violent disabled suspects. So that’s still an open question awaiting a case properly presenting it.

Disposing of the rest of the case

But then what happens to the case and its remaining questions, if the ADA question is dismissed? The six-justice majority decided that the officers deserved qualified immunity. Justice Scalia, joined by Justice Kagan, argued that San Francisco shouldn’t be given a win for “snookering” the Court, when the Court wouldn’t have answered the qualified immunity question if presented alone. Instead the Court should have dismissed the entire case, leaving San Francisco to its loss in the Ninth Circuit.

Thoughts

I previously wasn’t entirely certain that San Francisco had changed its argument. But in light of the Court’s unanimous agreement on the matter, and in light of other commentary, it seems clear that it did.

I wasn’t aware the Court could dismiss “half” a case; that seems reasonable for the ADA question. For the remainder of the case, I think I lean toward Scalia’s and Kagan’s view. It’s unfair to parties in cases to allow one side to make an argument, then not be held to that argument come decision time. But I didn’t trace the majority’s cites far enough to conclude that its position was definitely wrong, so count my agreement with Scalia and Kagan as only tentative.

Next time, discussion of the ultimate opinion in Walker v. Texas Division, Sons of Confederate Veterans. The case is still pending, so I can’t yet say when that post might be ready.

15.06.15

Final thoughts on Walker v. Texas Division, Sons of Confederate Veterans

Two months ago I began a blog post series about my recent visit to the Supreme Court for oral arguments in two cases. San Francisco v. Sheehan concerned police use of force in San Francisco; Walker v. Texas Division, Sons of Confederate Veterans concerned Texas’s specialty license plate program and its restrictions on permissible designs. Seven weeks ago I discussed oral argument in the Texas license plate case. Today I return for final thoughts on the Texas license plate case, in which a decision is expected any day now — perhaps even in an hour today.

(Why the seven-week delay when I’d promised merely “a day or two”? The day of the last post, I underwent [relatively] minor surgery for pain from a high ankle sprain, that hadn’t fully responded to approaches short of arthroscopic ankle surgery. [The surgery seems to have been successful, but I probably can’t be sure til I regain full ankle flexibility/strength. I can walk almost entirely normally now, but strength and flexibility are still noticeably diminished, albeit improving daily.] Although I had spare time immediately afterward, I wasn’t particularly inclined to post-writing, and as time passed I never got back in the groove. Time winding down before the ultimate opinion has put me back on track. 🙂 )

Back to forum analysis

Before I tackled oral argument, my previous posts discussed offensive speech. I left one question hanging: what sort of forum is Texas’s specialty license plate program? Is it a designated public forum or a limited public forum?

This turns out not to matter. To judge offensiveness requires adopting a particular viewpoint, but regardless which sort of forum Texas specialty plates are, restrictions must be viewpoint-neutral. As for Texas’s argument that judging offensiveness is “objective” and viewpoint-neutral, this plainly must fall in light of the Court’s repeated insistence that “the government may not prohibit the expression of an idea simply because society finds the idea itself offensive”.

Censoring based on offensiveness is not viewpoint-neutral. But in either a designated public forum or a limited public forum, restrictions must be viewpoint-neutral. So it doesn’t matter which Texas’s program is: prohibitions based on offensiveness must fall.

My opinion

On Texas

If you’ve paid any attention to this series, it should be obvious that I think Texas must lose. When Texas opened up a forum for speech on plates and invited essentially everyone onto them, they lost control over what can be said there. An amicus brief from the Rutherford Institute best captures my thoughts on this case. (Which isn’t to say I disagree with other briefs supporting Texas SCV, simply that the approach here best matches my reasoning.)

Other specialty plate programs

So much for Texas’s program. What about programs in other states? Such disputes previously have centered on Confederate flags (by other SCV divisions), but perhaps the most prominent topic of controversy has been adoption/abortion/pro-life/pro-choice advocacy. Some states have explicitly ordered designs taking sides in that controversy, or have approved such designs submitted by private parties. Inevitably the other side files suit for a chance to say its piece. What should happen? I think it depends on the contours of the program.

If a state legislature passes a law ordering a design be produced, or delegating that to the state DMV, that legitimately does seem to me to be government speech. Private parties have no right to butt in to demand alternative designs. The place to challenge such programs is in the voting booth, not the courthouse. The same is true if privately-submitted designs receive legislative approval in a pick-and-choose process: the available designs are government speech (although the designs themselves may be hybrid speech).

On the other hand, if a state provides a specialty plate program in which private parties may request designs, and those designs aren’t explicitly limited to particular topics, the specialty plate program is a designated public forum in which permitted private parties can say whatever they want. (Subject to the usual traditional public forum restrictions.) (This is Texas’s program.)

If the state provides an open program with restrictions, then we have a limited public forum. A specialty plate program along these lines might or might not be able to exclude speakers. For example, many Texas designs recognize particular colleges. A state program allowing only colleges to submit designs, consisting of a color scheme and a logo, wouldn’t be required to accept a specialty plate on some other topic, or from a non-college. A specialty plate program that allowed, say, “non-political” designs only would be a much closer question that would probably swing the other way. (Who’s to say what’s political and what isn’t, “viewpoint-neutrally”?) But if criteria were objective and viewpoint-neutral, restrictions might be permissible.

Justice Kennedy’s concern that striking Texas’s program “curtails” speech

One slightly disconcerting moment at oral argument came after Texas SCV argued that Texas pretty much couldn’t prohibit anything on specialty plates. With minor adjustments for readability:

Justice Scalia
So you’re — you’re really arguing for the abolition of Texas specialty plates, aren’t you? I couldn’t make a better argument for — in that direction than — than what you’ve been doing.
Mr. George
Well, we had got along without it a long time before we got it, and we can get along without it again.
Justice Kennedy
So in a way, your argument curtails speech?

I’m not sure whether this ever received an answer. But the answer I’d have given is simple: “We call Texas’s bluff.” As I’ve noted, other states have had to respond to court cases in favor of unliked speakers: on license plates, in Adopt-A-Highway programs, in municipal transit ad programs, and so on. The states and cities operating these programs generally haven’t shut down the programs to prevent undesirable speakers from speaking, and many don’t even adjust program parameters to work around court decisions. No matter what it might bluster, Texas won’t shut down its program if it loses. Only very few ill-mannered states are likely to pick up their toys and leave, rather than share them with speakers they don’t like.

Predictions

My prediction is that Texas will lose unanimously. The justices generally were somewhat taken aback by the sprawling assertions made by Texas SCV, but that seems only natural when good people contemplate potentially allowing vile, racist speech. The justices, as judges, ultimately must be, and are, less susceptible to these emotional tuggings than it might seem in the moment of argument. This is a very pro-speech Court; I think they’ll have very little trouble getting over their prejudices against speech they might not like.

Only Justice Scalia seemed to have particular sympathy for Texas, and for Texas being permitted to run its program however it wants. I think he viewed specialty plates and programs as mostly one giant exercise in frivolity: “Why aren’t bumper stickers good enough?”, “Why does anyone care what’s on their license plate?”, to put words in his mouth. There’s something to that: if we returned to a world where license plates were solid-color letters on a solid-color background, it’s hard to say anyone would really be much worse off. But just because a particular means of speech seems unbelievably stupid doesn’t justify shutting it down. I don’t think Justice Scalia would hang up on that in an opinion.

Ultimately I think the open nature of Texas’s invitation, combined with the standardless system by which Texas can reject designs, will sway him against Texas, even if he thinks the entire controversy is a waste of time. Justice Scalia was one of the votes striking down statutes criminalizing flag-burning on the basis of its offensiveness. I don’t see how he would abrogate that position on offensive speech just because Texas nominally exercises “effective[] control” over the specialty license plate program but doesn’t specifically cabin designs to limited topics.

Next time I return to San Francisco v. Sheehan to discuss the opinion in that case. And unlike last time, I’ll guarantee this discussion will issue tomorrow. (Barring Dreamhost downtime, server issues, Judgment Day, &c.) 🙂