Token type shouldn't be set after the other fields, to allow the setting of those fields to be asserted type-safe

RESOLVED FIXED in mozilla25

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: Waldo, Assigned: njn)

Tracking

Trunk
mozilla25
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
Currently we set fields like token.u.reflags before we set token.type.  This means that we can't assert that, when reflags is set, its type is TOK_REGEXP.  We should initialize in an order that makes such assertions possible, for all the various token-mutation methods.
(Assignee)

Comment 1

5 years ago
Created attachment 784788 [details] [diff] [review]
Do kind-checking in Token's setters.

In bug 898912, I thought about removing |tt| and just working directly with
|tp->type|, but I didn't end up doing it.

And then I saw this bug and realized that if I made that change it would be
really easy to fix.  So here you go.  The performance effect is negligible.
Attachment #784788 - Flags: review?(till)
(Assignee)

Updated

5 years ago
Assignee: general → n.nethercote
Comment on attachment 784788 [details] [diff] [review]
Do kind-checking in Token's setters.

Review of attachment 784788 [details] [diff] [review]:
-----------------------------------------------------------------

nice
Attachment #784788 - Flags: review?(till) → review+
https://hg.mozilla.org/mozilla-central/rev/786c07374154
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.