diff --git a/extractor/extractor.go b/extractor/extractor.go index e90bfede7e1..d4cedcbc5dd 100644 --- a/extractor/extractor.go +++ b/extractor/extractor.go @@ -352,6 +352,9 @@ func extractUniverseScope() { lbl := tw.Labeler.ScopeID(types.Universe, nil) dbscheme.ScopesTable.Emit(tw, lbl, dbscheme.UniverseScopeType.Index()) extractObjects(tw, types.Universe, lbl) + + // Always extract an empty interface type + extractType(tw, types.NewInterfaceType([]*types.Func{}, []types.Type{})) } // extractObjects extracts all objects declared in the given scope diff --git a/ql/test/extractor-tests/empty-interface/tst.expected b/ql/test/extractor-tests/empty-interface/tst.expected new file mode 100644 index 00000000000..cb2f8ad3b31 --- /dev/null +++ b/ql/test/extractor-tests/empty-interface/tst.expected @@ -0,0 +1 @@ +| success | diff --git a/ql/test/extractor-tests/empty-interface/tst.go b/ql/test/extractor-tests/empty-interface/tst.go new file mode 100644 index 00000000000..e5d8097fae4 --- /dev/null +++ b/ql/test/extractor-tests/empty-interface/tst.go @@ -0,0 +1,9 @@ +package main + +// This file tests that the extractor does not crash on files that do not +// end in a newline, so it is important not to autoformat this file. + +// autoformat-ignore + +func main() { +} \ No newline at end of file diff --git a/ql/test/extractor-tests/empty-interface/tst.ql b/ql/test/extractor-tests/empty-interface/tst.ql new file mode 100644 index 00000000000..4cd2d43d823 --- /dev/null +++ b/ql/test/extractor-tests/empty-interface/tst.ql @@ -0,0 +1,4 @@ +import go + +where exists(InterfaceType empty | not empty.hasMethod(_, _)) +select "success"