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
{{ message }}
Repository navigation
Commit 629ea53
Browse filesBrowse the repository at this point in the historyBrowse files
Make modules named in @throws dependencies and name nested exceptions exactly
Why:
Review of #9198: the type checker loads the module a @throws names, but
the dependency scanner skipped attributes. A module named only there was
built in any order, so the name resolved or got warning 113 depending
on the build, and a later edit could fail with "inconsistent
assumptions". Messages also named an exception defined in a nested
module without that module, so the annotation they suggested did not
resolve. And a library built with -no-keep-locs recorded its own
exceptions with its file, while its users see them without one.
`Depend` now adds the modules a @throws names, like any other use, so
they are built first. A module that is both named in @throws and depends
on the annotating module now gives a dependency cycle error.
`Typemod` records which module of the current file defines each
exception and module, so a file's own exception is named `Lib.Inner.F`.
Under -no-keep-locs a file's own exceptions are identified by name alone
also while it is compiled. Warning 113 is shown once for a `let` that
destructures a tuple.
Diagnostic modified (an exception of a nested module):
Example:
// ThrowsLibExn.res
module Inner = {
exception F
@throws(F)
external find: int => int = "findThrowing"
}
// ThrowsLibExnCalls.res
let uncaughtNested = x => ThrowsLibExn.Inner.find(x)
Before (reanalyze): tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ThrowsLibExnCalls.res
Exception Analysis
ThrowsLibExnCalls.res:110:5-18
uncaughtNested might throw ThrowsLibExn.F (ThrowsLibExnCalls.res:110:26) and is not annotated with @throws(ThrowsLibExn.F)
After (reanalyze): tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ThrowsLibExnCalls.res
Exception Analysis
ThrowsLibExnCalls.res:110:5-18
uncaughtNested might throw ThrowsLibExn.Inner.F (ThrowsLibExnCalls.res:110:26) and is not annotated with @throws(ThrowsLibExn.Inner.F)
Diagnostic modified (a module named only in @throws, tests/build_tests/throws_dependency):
Example:
// A.res
@throws(Z.E)
external find: int => int = "find"
// Z.res
exception E
Before (diagnostic): A.res built before Z.res
Warning number 113
@throws names Z.E, which is not an exception in scope here. Exception analysis cannot match it with the exceptions callers catch.
After (diagnostic): Z.res built first, no warning
Breaking: A module named in @throws that itself depends on the annotating module is now a dependency cycle. Move the exception to a module of its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gHA54VKxsXvCQyC2vw
Signed-off-by: Christoph Knittel <ck@cca.io>
- A module named in `@throws` is now a dependency of the module that names it, so a dependency cycle through such a name is an error. Move the exception to a module of its own.
0 commit comments