flomesh-io / pipy

Pipy is a programmable proxy for the cloud, edge and IoT.
https://flomesh.io/pipy
Other
743 stars 70 forks source link

Prompted wrong js filename when calling a function in a module with an error. #128

Closed wanpf closed 1 year ago

wanpf commented 1 year ago

Steps to reproduce

// file main.js

1 2 (( 3 { 4 funcTest 5 } = pipy.solve('module.js')) => ( 6 7 funcTest(), 8 9 pipy({ 10 }) 11 12 ) 13 14 )() 15 16

// file module.js

1 2 ( 3 (module) => ( 4 5 module = {}, 6 7 module.funcTest = () => ( 8 console.log('hello', var1) 9 ), 10 11 module 12 ) 13 14 )() 15 16

run pipy main.js

2022-11-01 14:50:12.628 [ERR] [pjs] File /main.js: 2022-11-01 14:50:12.628 [ERR] [pjs] Line 8: 2022-11-01 14:50:12.628 [ERR] [pjs] ^ 2022-11-01 14:50:12.628 [ERR] [pjs] Error: unresolved identifier 2022-11-01 14:50:12.628 [ERR] [pjs] Backtrace: 2022-11-01 14:50:12.628 [ERR] In (anonymous function at line 7 column 23) at line 8 column 28 2022-11-01 14:50:12.628 [ERR] In (anonymous function at line 2 column 2) at line 7 column 11 2022-11-01 14:50:12.628 [ERR] In (root) at line 14 column 2 2022-11-01 14:50:12.628 [INF] [shutdown] Shutting down... 2022-11-01 14:50:12.628 [INF] [shutdown] Stopped. Done.

naqvis commented 1 year ago

Confirmed commit #https://github.com/flomesh-io/pipy/commit/e5d2a5c1e701972e6690d6fd514bfa5f658f370e

output generated with fixed commit

2022-11-03 01:13:20.304 [ERR] [pjs] File module.js:
2022-11-03 01:13:20.304 [ERR] [pjs] Line 8:  console.log('hello', var1)
2022-11-03 01:13:20.304 [ERR] [pjs]                               ^
2022-11-03 01:13:20.304 [ERR] [pjs] Error: unresolved identifier
2022-11-03 01:13:20.304 [ERR] [pjs] Backtrace:
2022-11-03 01:13:20.304 [ERR]     In (anonymous function at line 7 column 23) at line 8 column 26 in module.js
2022-11-03 01:13:20.304 [ERR]     In (anonymous function at line 2 column 2) at line 7 column 10 in /main.js
2022-11-03 01:13:20.304 [ERR]     In (root) at line 14 column 2 in /main.js
2022-11-03 01:13:20.304 [INF] [shutdown] Shutting down...
2022-11-03 01:13:20.304 [INF] [shutdown] Stopped.
Done.

@wanpf please help to confirm the fix.