File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed
Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " jspython-interpreter" ,
3- "version" : " 2.0.5 " ,
3+ "version" : " 2.0.7 " ,
44 "description" : " JSPython is a javascript implementation of Python language that runs within web browser or NodeJS environment" ,
55 "keywords" : [
66 " python" ,
Original file line number Diff line number Diff line change @@ -230,6 +230,10 @@ export class Evaluator {
230230 if ( node . type === "funcCall" ) {
231231 const funcCallNode = node as FunctionCallNode ;
232232 const func = blockContext . blockScope . get ( funcCallNode . name ) as ( ...args : unknown [ ] ) => unknown ;
233+ if ( typeof func !== 'function' ) {
234+ throw Error ( `'${ funcCallNode . name } ' is not a function or not defined.` )
235+ }
236+
233237 const pms = funcCallNode . paramNodes ?. map ( n => this . evalNode ( n , blockContext ) ) || [ ]
234238
235239 return this . invokeFunction ( func , pms ) ;
@@ -296,6 +300,10 @@ export class Evaluator {
296300 const funcCallNode = nestedProp as FunctionCallNode ;
297301 const func = startObject [ funcCallNode . name ] as ( ...args : unknown [ ] ) => unknown ;
298302
303+ if ( typeof func !== 'function' ) {
304+ throw Error ( `'${ funcCallNode . name } ' is not a function or not defined.` )
305+ }
306+
299307 if ( func === undefined
300308 && ( dotObject . nestedProps [ i - 1 ] as unknown as IsNullCoelsing ) . nullCoelsing ) {
301309 continue ;
Original file line number Diff line number Diff line change @@ -237,7 +237,12 @@ export class EvaluatorAsync {
237237 if ( node . type === "funcCall" ) {
238238 const funcCallNode = node as FunctionCallNode ;
239239 const func = blockContext . blockScope . get ( funcCallNode . name ) as ( ...args : unknown [ ] ) => unknown ;
240- const pms = [ ]
240+
241+ if ( typeof func !== 'function' ) {
242+ throw Error ( `'${ funcCallNode . name } ' is not a function or not defined.` )
243+ }
244+
245+ const pms = [ ] ;
241246 for ( let p of funcCallNode . paramNodes || [ ] ) {
242247 pms . push ( await this . evalNodeAsync ( p , blockContext ) ) ;
243248 }
@@ -311,6 +316,9 @@ export class EvaluatorAsync {
311316 continue ;
312317 }
313318
319+ if ( typeof ( func ) !== 'function' ) {
320+ throw Error ( `'${ funcCallNode . name } ' is not a function or not defined.` )
321+ }
314322 const pms = [ ]
315323 for ( let p of funcCallNode . paramNodes || [ ] ) {
316324 pms . push ( await this . evalNodeAsync ( p , blockContext ) ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { parseDatetimeOrNull } from "./common/utils";
22
33export const INITIAL_SCOPE = {
44 jsPython ( ) : string {
5- return [ `JSPython v2.0.4 ` , "(c) FalconSoft Ltd" ] . join ( '\n' )
5+ return [ `JSPython v2.0.7 ` , "(c) FalconSoft Ltd" ] . join ( '\n' )
66 } ,
77 dateTime : ( str : number | string | any = null ) => ( str && str . length )
88 ? parseDatetimeOrNull ( str ) || new Date ( ) : new Date ( ) ,
You can’t perform that action at this time.
0 commit comments