Skip to content

Commit ea8303e

Browse files
authored
fix: handle tokens where start idx is greater than end idx
PR-URL: #2770 Signed-off-by: Snehil Shah <snehilshah.989@gmail.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 6a150d1 commit ea8303e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/node_modules/@stdlib/repl/lib/tokenizer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function tokenizer( line, context ) {
103103
*/
104104
function onToken( token ) {
105105
// Ignore placeholders & EOF tokens:
106-
if ( token.start === token.end ) {
106+
if ( token.start >= token.end ) {
107107
return;
108108
}
109109
if ( token.type.isLoop || isControlKeyword( token.type.keyword ) || ( token.type.label === 'name' && isUnrecognizedControlKeyword( token.value ) ) ) {
@@ -196,7 +196,7 @@ function tokenizer( line, context ) {
196196
var i;
197197

198198
// Ignore placeholder nodes:
199-
if ( node.start === node.end ) {
199+
if ( node.start >= node.end ) {
200200
return true;
201201
}
202202
// Ignore node if it is an unrecognized `keyword`:
@@ -275,7 +275,7 @@ function tokenizer( line, context ) {
275275
var obj;
276276

277277
// Ignore placeholder nodes:
278-
if ( node.start === node.end ) {
278+
if ( node.start >= node.end ) {
279279
return;
280280
}
281281

@@ -308,7 +308,7 @@ function tokenizer( line, context ) {
308308
property = properties.next();
309309
while ( !property.done ) {
310310
// Ignore placeholder nodes:
311-
if ( property.value.start === property.value.end ) {
311+
if ( property.value.start >= property.value.end ) {
312312
return;
313313
}
314314
// Case: 'bar' in `foo['bar']` - property already pushed as a string token. Ignore...

0 commit comments

Comments
 (0)