From ead04e5a2943a573af7179ad6b841ecd65e2b56a Mon Sep 17 00:00:00 2001 From: Kevin Barabash Date: Sun, 19 Aug 2018 10:44:11 -0400 Subject: [PATCH] make SourceLocation fields readonly (#1637) --- src/SourceLocation.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/SourceLocation.js b/src/SourceLocation.js index 68da356c..6fb74b6d 100644 --- a/src/SourceLocation.js +++ b/src/SourceLocation.js @@ -6,16 +6,15 @@ import type {LexerInterface} from "./Token"; * This object is immutable. */ export default class SourceLocation { - lexer: LexerInterface; // Lexer holding the input string. - start: number; // Start offset, zero-based inclusive. - end: number; // End offset, zero-based exclusive. + // The + prefix indicates that these fields aren't writeable + +lexer: LexerInterface; // Lexer holding the input string. + +start: number; // Start offset, zero-based inclusive. + +end: number; // End offset, zero-based exclusive. constructor(lexer: LexerInterface, start: number, end: number) { this.lexer = lexer; this.start = start; this.end = end; - // $FlowFixMe, do not polyfill - Object["freeze"](this); // Immutable to allow sharing in range(). } /**