MCPcopy
hub / github.com/google/mangle / checkVisibility

Method checkVisibility

analysis/validation.go:885–909  ·  view source on GitHub ↗
(clause ast.Clause)

Source from the content-addressed store, hash-verified

883}
884
885func (a *Analyzer) checkVisibility(clause ast.Clause) error {
886 var pkg string
887 symbol := clause.Head.Predicate.Symbol
888 if lastDot := strings.LastIndex(symbol, "."); lastDot != -1 {
889 pkg = symbol[:lastDot]
890 } else {
891 pkg = ""
892 }
893 return a.check(func(sym ast.PredicateSym) error {
894 d, ok := a.decl[sym]
895 if !ok {
896 // TODO: Invert default visibility.
897 // No decl found. Assume public visibility.
898 return nil
899 }
900 // Predicates defined in the same package are visible.
901 if pkg == d.PackageID() {
902 return nil
903 }
904 if !d.Visible() {
905 return fmt.Errorf("predicate %q is not public", sym)
906 }
907 return nil
908 }, clause)
909}
910
911func (a *Analyzer) checkExprArity(arg ast.BaseTerm) error {
912 switch x := arg.(type) {

Callers 1

CheckRuleMethod · 0.95

Calls 3

checkMethod · 0.95
PackageIDMethod · 0.80
VisibleMethod · 0.80

Tested by

no test coverage detected