Skip to content
/ repl Public

Commit 3384d10

Browse files
committed
Auto-generated commit
1 parent b16d419 commit 3384d10

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727

2828
<!-- /.features -->
2929

30+
<section class="bug-fixes">
31+
32+
##### Bug Fixes
33+
34+
- [`2de9ed7`](https://github.com/stdlib-js/stdlib/commit/2de9ed76d79a2f10a26a5246077199cf70819a89) - guard against proxy traps raising exceptions in REPL tokenizer [(#4457)](https://github.com/stdlib-js/stdlib/pull/4457)
35+
36+
</section>
37+
38+
<!-- /.bug-fixes -->
39+
3040
</details>
3141

3242
</section>
@@ -180,6 +190,7 @@ A total of 4 people contributed to this release. Thank you to the following cont
180190

181191
<details>
182192

193+
- [`2de9ed7`](https://github.com/stdlib-js/stdlib/commit/2de9ed76d79a2f10a26a5246077199cf70819a89) - **fix:** guard against proxy traps raising exceptions in REPL tokenizer [(#4457)](https://github.com/stdlib-js/stdlib/pull/4457) _(by Snehil Shah)_
183194
- [`8dfa851`](https://github.com/stdlib-js/stdlib/commit/8dfa8515051fc7dde731cd8373b17377c7f015b8) - **docs:** update REPL namespace documentation [(#4447)](https://github.com/stdlib-js/stdlib/pull/4447) _(by stdlib-bot)_
184195
- [`b718cde`](https://github.com/stdlib-js/stdlib/commit/b718cde9cbff4b49da9caa3282dc72969243903b) - **docs:** update REPL namespace documentation [(#4427)](https://github.com/stdlib-js/stdlib/pull/4427) _(by stdlib-bot, Philipp Burckhardt)_
185196
- [`8d7f8e2`](https://github.com/stdlib-js/stdlib/commit/8d7f8e26975ffa5ca2ff11a24eac5f3bba589104) - **refactor:** add specialized handling for displaying ndarrays _(by Athan Reines)_

lib/tokenizer.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
var parse = require( 'acorn-loose' ).parse;
2626
var walk = require( 'acorn-walk' );
27+
var hasProp = require( '@stdlib/assert/has-property' );
2728
var linkedList = require( '@stdlib/utils/linked-list' );
2829
var contains = require( '@stdlib/array/base/assert/contains' );
2930
var resolveLocalScopes = require( './resolve_local_scopes.js' );
@@ -227,7 +228,7 @@ function tokenizer( line, context ) {
227228
for ( i = 0; i < COMMANDS.length; i++ ) {
228229
command = COMMANDS[ i ];
229230
if ( node.name === command[ 0 ] ) {
230-
tokens.push( {
231+
tokens.push({
231232
'value': node.name,
232233
'type': 'command',
233234
'start': node.start,
@@ -240,14 +241,14 @@ function tokenizer( line, context ) {
240241
identifier = context[ node.name ];
241242
if ( identifier ) {
242243
if ( isLiteralType( typeof identifier ) ) {
243-
tokens.push( {
244+
tokens.push({
244245
'value': node.name,
245246
'type': 'variable',
246247
'start': node.start,
247248
'end': node.end
248249
});
249250
} else {
250-
tokens.push( {
251+
tokens.push({
251252
'value': node.name,
252253
'type': typeof identifier,
253254
'start': node.start,
@@ -313,19 +314,27 @@ function tokenizer( line, context ) {
313314
}
314315
// Case: 'bar' in `foo['bar']` - property already pushed as a string token. Ignore...
315316
if ( property.value.type === 'Literal' ) {
316-
obj = obj[ property.value.value ];
317-
if ( !obj ) {
318-
// Property not found in context:
317+
try {
318+
if ( !hasProp( obj, property.value.value ) ) {
319+
// Property not found in context:
320+
break;
321+
}
322+
obj = obj[ property.value.value ];
323+
} catch ( error ) { // eslint-disable-line no-unused-vars
319324
break;
320325
}
321326
property = properties.next();
322327
continue;
323328
}
324329
// Case: `foo.bar` - resolve property and push it as a token...
325330
if ( property.value.type === 'Identifier' ) {
326-
obj = obj[ property.value.name ];
327-
if ( !obj ) {
328-
// Property not found in context:
331+
try {
332+
if ( !hasProp( obj, property.value.name ) ) {
333+
// Property not found in context:
334+
break;
335+
}
336+
obj = obj[ property.value.name ];
337+
} catch ( error ) { // eslint-disable-line no-unused-vars
329338
break;
330339
}
331340
if ( !compute ) {
@@ -356,9 +365,13 @@ function tokenizer( line, context ) {
356365
// Couldn't compute the internal `MemberExpression` into a definite name:
357366
break;
358367
}
359-
obj = obj[ computed ];
360-
if ( !obj ) {
361-
// Property not found in context:
368+
try {
369+
if ( !hasProp( obj, computed ) ) {
370+
// Property not found in context:
371+
break;
372+
}
373+
obj = obj[ computed ];
374+
} catch ( error ) { // eslint-disable-line no-unused-vars
362375
break;
363376
}
364377
property = properties.next();

0 commit comments

Comments
 (0)