File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
tests/functional/syntax/modules Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -466,3 +466,19 @@ def __init__():
466
466
with pytest .raises (InterfaceViolation ) as e :
467
467
compile_code (main , input_bundle = input_bundle )
468
468
assert e .value ._message == "requested `lib1.ifoo` but `lib1` does not implement `lib1.ifoo`!"
469
+
470
+
471
+ def test_export_empty_interface (make_input_bundle ):
472
+ lib1 = """
473
+ def an_internal_function():
474
+ pass
475
+ """
476
+ main = """
477
+ import lib1
478
+
479
+ exports: lib1.__interface__
480
+ """
481
+ input_bundle = make_input_bundle ({"lib1.vy" : lib1 })
482
+ with pytest .raises (StructureException ) as e :
483
+ compile_code (main , input_bundle = input_bundle )
484
+ assert e .value ._message == "lib1 has no external functions!"
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ class AnalysisResult:
96
96
class ModuleInfo (AnalysisResult ):
97
97
module_t : "ModuleT"
98
98
alias : str
99
+ # import_node: vy_ast._ImportStmt # maybe could be useful
99
100
ownership : ModuleOwnership = ModuleOwnership .NO_OWNERSHIP
100
101
ownership_decl : Optional [vy_ast .VyperNode ] = None
101
102
Original file line number Diff line number Diff line change @@ -528,6 +528,12 @@ def visit_ExportsDecl(self, node):
528
528
for fn in interface_t .functions .values ()
529
529
if fn .is_external
530
530
]
531
+
532
+ if len (funcs ) == 0 :
533
+ path = module_info .module_node .path
534
+ msg = f"{ module_info .alias } (located at `{ path } `) has no external functions!"
535
+ raise StructureException (msg , item )
536
+
531
537
else :
532
538
raise StructureException (
533
539
f"not a function or interface: `{ info .typ } `" , info .typ .decl_node , item
You can’t perform that action at this time.
0 commit comments