Skip to content

Commit 82e01c7

Browse files
authored
Fix ocamlobjinfo output parsing (#12767)
Do not stop parsing once we run into an unrecognized lined. Skip it and continue parsing. Signed-off-by: Rudi Grinberg <[email protected]>
1 parent d8314f0 commit 82e01c7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/dune_rules/ocamlobjinfo.mll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ and intfs acc_units acc = parse
3131
| ws hash ws (name as name) newline { intfs acc_units (add_intf acc name) lexbuf }
3232
| "Implementations imported:" newline { impls acc_units acc lexbuf }
3333
| "File " [^ '\n']+ newline { ocamlobjinfo (acc :: acc_units) empty lexbuf }
34+
| [^ '\n' ]* newline { intfs acc_units acc lexbuf }
3435
| _ | eof { acc :: acc_units }
3536
and impls acc_units acc = parse
3637
| ws hash ws (name as name) newline { impls acc_units (add_impl acc name) lexbuf }
3738
| "File " [^ '\n']+ newline { ocamlobjinfo (acc :: acc_units) empty lexbuf }
39+
| [^ '\n' ]* newline { impls acc_units acc lexbuf }
3840
| _ | eof { acc :: acc_units }
3941

4042
and archive acc = parse

test/expect-tests/ocamlobjinfo_tests.ml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,33 @@ let%expect_test "parse_archive extracts unit names" =
225225
set { "bar"; "foo"; "helper" }
226226
|}]
227227
;;
228+
229+
let%expect_test "regression test" =
230+
parse
231+
{fixture|
232+
File foo/bar.cmo
233+
Unit name: Bar
234+
Interfaces imported:
235+
03e897aee435213573adf13c80fcb505 M1
236+
863a7f5288599b181f046f0f55277b0f M2
237+
Required globals:
238+
X
239+
Uses unsafe features: no
240+
Force link: no
241+
File foo/baz.cmo
242+
Unit name: Baz
243+
Interfaces imported:
244+
1b835c1e0367d04fd16979463a84a7cd M3
245+
6b06eead182e9e338552e756d414f9e8 M4
246+
Required globals:
247+
Y
248+
Uses unsafe features: no
249+
Force link: no
250+
|fixture};
251+
[%expect
252+
{|
253+
[ { impl = set {}; intf = set { "m1"; "m2" } }
254+
; { impl = set {}; intf = set { "m3"; "m4" } }
255+
]
256+
|}]
257+
;;

0 commit comments

Comments
 (0)