Skip to content

Commit

Permalink
fix: handle tokens where start idx is greater than end idx
Browse files Browse the repository at this point in the history
PR-URL: #2770

Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
  • Loading branch information
Snehil-Shah authored Aug 10, 2024
1 parent 6a150d1 commit ea8303e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/repl/lib/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function tokenizer( line, context ) {
*/
function onToken( token ) {
// Ignore placeholders & EOF tokens:
if ( token.start === token.end ) {
if ( token.start >= token.end ) {
return;
}
if ( token.type.isLoop || isControlKeyword( token.type.keyword ) || ( token.type.label === 'name' && isUnrecognizedControlKeyword( token.value ) ) ) {
Expand Down Expand Up @@ -196,7 +196,7 @@ function tokenizer( line, context ) {
var i;

// Ignore placeholder nodes:
if ( node.start === node.end ) {
if ( node.start >= node.end ) {
return true;
}
// Ignore node if it is an unrecognized `keyword`:
Expand Down Expand Up @@ -275,7 +275,7 @@ function tokenizer( line, context ) {
var obj;

// Ignore placeholder nodes:
if ( node.start === node.end ) {
if ( node.start >= node.end ) {
return;
}

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

1 comment on commit ea8303e

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
repl $\color{red}10404/12996$
$\color{green}+80.06\%$
$\color{red}631/862$
$\color{green}+73.20\%$
$\color{red}146/232$
$\color{green}+62.93\%$
$\color{red}10404/12996$
$\color{green}+80.06\%$

The above coverage report was generated for the changes in this push.

Please # to comment.