11import * as w from '../warnings.js' ;
22import { get_proxied_value } from '../proxy.js' ;
33
4+ /**
5+ * @param {any } v
6+ */
7+ function is_object ( v ) {
8+ return typeof v === 'object' && v !== null ;
9+ }
10+
411export function init_array_prototype_warnings ( ) {
512 const array_prototype = Array . prototype ;
613 // The REPL ends up here over and over, and this prevents it from adding more and more patches
@@ -16,7 +23,7 @@ export function init_array_prototype_warnings() {
1623 array_prototype . indexOf = function ( item , from_index ) {
1724 const index = indexOf . call ( this , item , from_index ) ;
1825
19- if ( index === - 1 ) {
26+ if ( index === - 1 && is_object ( item ) ) {
2027 const test = indexOf . call ( get_proxied_value ( this ) , get_proxied_value ( item ) , from_index ) ;
2128
2229 if ( test !== - 1 ) {
@@ -32,7 +39,7 @@ export function init_array_prototype_warnings() {
3239 // `arguments` inside so passing undefined is different from not passing anything
3340 const index = lastIndexOf . call ( this , item , from_index ?? this . length - 1 ) ;
3441
35- if ( index === - 1 ) {
42+ if ( index === - 1 && is_object ( item ) ) {
3643 // we need to specify this.length - 1 because it's probably using something like
3744 // `arguments` inside so passing undefined is different from not passing anything
3845 const test = lastIndexOf . call (
@@ -52,7 +59,7 @@ export function init_array_prototype_warnings() {
5259 array_prototype . includes = function ( item , from_index ) {
5360 const has = includes . call ( this , item , from_index ) ;
5461
55- if ( ! has ) {
62+ if ( ! has && is_object ( item ) ) {
5663 const test = includes . call ( get_proxied_value ( this ) , get_proxied_value ( item ) , from_index ) ;
5764
5865 if ( test ) {
0 commit comments