You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if l.contains(sl) || after_colon(l).contains(after_colon(sl)){
161
+
// `fmtd_msg` contains `short_msg`.
162
+
if l.bytes().filter(|b| *b == b':').count() >= 3{
163
+
// This is an old style error message, like:
164
+
// path/to/file:line:column: ErrorType: message
165
+
// We want to display this as-is.
166
+
}else{
167
+
// Otherwise, assume that the messages are the same until we find a source
168
+
// location.
169
+
lines.next();
170
+
while lines.clone().next().is_some_and(|l| !l.contains("-->")){
171
+
lines.next();
172
+
}
173
+
}
174
+
}
159
175
}
160
176
161
-
// format the main source location
177
+
// Format the main source location.
162
178
fmt_source_location(f,&mut lines)?;
163
179
164
-
// format remaining lines as secondary locations
180
+
// Format remaining lines as secondary locations.
165
181
whileletSome(line) = lines.next(){
166
182
f.write_str("\n")?;
167
183
@@ -404,7 +420,7 @@ mod tests {
404
420
}
405
421
406
422
#[test]
407
-
fnsolc_not_formatting_the_message1(){
423
+
fnno_source_location(){
408
424
let error = r#"{"component":"general","errorCode":"6553","formattedMessage":"SyntaxError: The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction.\n\n","message":"The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction.","severity":"error","sourceLocation":{"end":173,"file":"","start":114},"type":"SyntaxError"}"#;
409
425
let error = serde_json::from_str::<Error>(error).unwrap();
410
426
let s = error.to_string();
@@ -414,12 +430,22 @@ mod tests {
414
430
}
415
431
416
432
#[test]
417
-
fnsolc_not_formatting_the_message2(){
433
+
fnno_source_location2(){
418
434
let error = r#"{"component":"general","errorCode":"5667","formattedMessage":"Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.\n\n","message":"Unused function parameter. Remove or comment out the variable name to silence this warning.","severity":"warning","sourceLocation":{"end":104,"file":"","start":95},"type":"Warning"}"#;
419
435
let error = serde_json::from_str::<Error>(error).unwrap();
420
436
let s = error.to_string();
421
437
eprintln!("{s}");
422
438
assert!(s.contains("Warning (5667)"),"\n{s}");
423
439
assert!(s.contains("Unused function parameter. Remove or comment out the variable name to silence this warning."),"\n{s}");
424
440
}
441
+
442
+
#[test]
443
+
fnstack_too_deep_multiline(){
444
+
let error = r#"{"sourceLocation":{"file":"test/LibMap.t.sol","start":15084,"end":15113},"type":"YulException","component":"general","severity":"error","errorCode":null,"message":"Yul exception:Cannot swap Variable _23 with Slot RET[fun_assertEq]: too deep in the stack by 1 slots in [ var_136614_mpos RET _23 _21 _23 var_map_136608_slot _34 _34 _29 _33 _33 _39 expr_48 var_bitWidth var_map_136608_slot _26 _29 var_bitWidth TMP[eq, 0] RET[fun_assertEq] ]\nmemoryguard was present.","formattedMessage":"YulException: Cannot swap Variable _23 with Slot RET[fun_assertEq]: too deep in the stack by 1 slots in [ var_136614_mpos RET _23 _21 _23 var_map_136608_slot _34 _34 _29 _33 _33 _39 expr_48 var_bitWidth var_map_136608_slot _26 _29 var_bitWidth TMP[eq, 0] RET[fun_assertEq] ]\nmemoryguard was present.\n --> test/LibMap.t.sol:461:34:\n |\n461 | uint256 end = t.o - (t.o > 0 ? _random() % t.o : 0);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"}"#;
445
+
let error = serde_json::from_str::<Error>(error).unwrap();
0 commit comments