@@ -1180,18 +1180,17 @@ void build_backtrace(JSContext* ctx, JSValueConst error_obj, const char* filenam
11801180 if (b -> has_debug ) {
11811181 /* find line and column, default to 1:1 */
11821182 line_num = find_line_num (ctx , b , sf -> cur_pc - b -> byte_code_buf - 1 );
1183- line_num = line_num == -1 ? 1 : line_num ;
1183+ line_num = line_num == -1 ? b -> debug . line_num : line_num ;
11841184 column_num = find_column_num (ctx , b , sf -> cur_pc - b -> byte_code_buf - 1 );
1185- column_num = column_num == -1 ? 1 : column_num + 1 ;
1185+ column_num = column_num == -1 ? b -> debug . column_num : column_num + 1 ;
11861186 atom_str = JS_AtomToCString (ctx , b -> debug .filename );
11871187 dbuf_printf (& dbuf , " (%s" , atom_str ? atom_str : "<null>" );
11881188 JS_FreeCString (ctx , atom_str );
1189- if (line_num != -1 ){
1189+ if (line_num != -1 ) {
11901190 dbuf_printf (& dbuf , ":%d" , line_num );
1191- }
1192-
1193- if (column_num != -1 ){
1194- dbuf_printf (& dbuf , ":%d" , column_num );
1191+ if (column_num != -1 ) {
1192+ dbuf_printf (& dbuf , ":%d" , column_num );
1193+ }
11951194 }
11961195
11971196 dbuf_putc (& dbuf , ')' );
@@ -1216,8 +1215,13 @@ void build_backtrace(JSContext* ctx, JSValueConst error_obj, const char* filenam
12161215
12171216 dbuf_free (& dbuf );
12181217 JS_DefinePropertyValue (ctx , error_obj , JS_ATOM_stack , str , JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE );
1219- JS_DefinePropertyValue (ctx , error_obj , JS_ATOM_lineNumber , JS_NewInt32 (ctx , line_num ), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE );
1220- JS_DefinePropertyValue (ctx , error_obj , JS_ATOM_columnNumber , JS_NewInt32 (ctx , column_num ), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE );
1218+
1219+ if (line_num != -1 ) {
1220+ JS_DefinePropertyValue (ctx , error_obj , JS_ATOM_lineNumber , JS_NewInt32 (ctx , line_num ), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE );
1221+ if (column_num != -1 ) {
1222+ JS_DefinePropertyValue (ctx , error_obj , JS_ATOM_columnNumber , JS_NewInt32 (ctx , column_num ), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE );
1223+ }
1224+ }
12211225}
12221226
12231227/* Note: it is important that no exception is returned by this function */
0 commit comments