Skip to content

Read the class of an @instanceOf type from its @module and @scope - #9309

Merged
tsnobip merged 3 commits into
masterfrom
module-instanceof
Nov 16, 2026
Merged

tsnobip merged 3 commits into
masterfrom
module-instanceof

Conversation

@tsnobip

@tsnobip tsnobip commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

@module and @scope on an @instanceOf type were silently ignored, so the class check of an untagged variant read a global of the class's name (#9239). For a class from a JavaScript library or a local file that global doesn't exist, and the check threw a ReferenceError.

@instanceOf("Object3D") type object3D
@module("three") @instanceOf("Mesh") type mesh = private object3D
@scope("THREE") @instanceOf("Line") type line = private object3D

In an @unboxed variant of these, the checks were s instanceof Mesh and s instanceof Line, with no import. They are now s instanceof Three.Mesh, with three imported the way a @module external imports it, and s instanceof THREE.Line.

  • Where the class is found. @module("m") reads the @instanceOf path among the exports of m, with "default" for the default export. @scope puts its properties in front of the path, so @scope("THREE") @instanceOf("Mesh") means @instanceOf("THREE.Mesh"). The check builds its constructor with translate_scoped_module_val, the code @module externals use, so the module that compiles the match gets the import, wherever the type is declared.
  • Class identity. A class is now its path and its module (Variant_runtime.Instance.class_name). A global Mesh and the Mesh that "three" exports are two cases of one variant, an interface must state the same module as its implementation, and subclass ordering compares both. Errors print such a class as Mesh from "three", and printed declarations show @module("three") @instanceOf("Mesh").
  • Errors instead of silence. It's now an error, reported at the attribute that's wrong, when:
    • @module isn't a single string;
    • with @module, the @instanceOf path isn't a valid export path;
    • @scope isn't a list of property names;
    • without @module, the first scope is a keyword or globalThis.
  • Breaking: errors on types without a class. @module or @scope on a type declaration without @instanceOf (a plain type, a record, a @typeOf or @notUndefined type) is now an error instead of being ignored, as suggested in review. Silently ignoring them is how @module on an @instanceOf type is silently ignored #9239 went unnoticed. Code that breaks only has an attribute that never did anything, and the migration is to remove it. This has its own breaking changelog fragment. The check runs where a declaration is type-checked, so interfaces already compiled by an older compiler still load.

A known limitation, shared with @module externals: a relative path such as @module("./x.js") is emitted as written, relative to the module that compiles the check.

Tests:

  • tests/tests/src/untagged_module_class_test.res runs named, scoped and default exports, a global that has an export's name, and a type declared in another module.
  • A super_errors fixture covers each new or changed diagnostic.
  • The dispatch unit tests cover subclass ordering across modules.

The docs are updated in compiler/ml/UntaggedVariants.md and in the @instanceOf completion doc.

Fixes #9239

Checklist

  • Added a changelog fragment (see changes/README.md), or no release notes are needed and a maintainer should apply changelog:skip.
  • Added tests for the fix or feature.
  • Gave every commit a description below its subject, saying why it is made (see "Commit messages" in CONTRIBUTING.md).
  • Signed off every commit for the DCO (git commit -s).

🤖 Generated with Claude Code

Why:
    `@module` and `@scope` on an `@instanceOf` type were silently ignored
    (#9239), so the class check of an untagged variant read a global of the
    class's name. For a class of a JavaScript library or a local file that
    global does not exist, and the check threw a ReferenceError. Like an
    external, the type now says where its class is found: `@module("m")`
    reads it among the exports of `m`, `"default"` for the default export,
    imported as a `@module` external imports it, and `@scope` puts its
    properties in front of the path.

JS modified (class check of an @instanceof type):
Example:
    @instanceof("Object3D") type object3D
    @module("three") @instanceof("Mesh") type mesh = private object3D
    @scope("THREE") @instanceof("Line") type line = private object3D

    @unboxed
    type shape = Mesh(mesh) | Line(line) | Other(object3D)

    let kind = s =>
      switch s {
      | Mesh(_) => "mesh"
      | Line(_) => "line"
      | Other(_) => "other"
      }
Before (js):
    function kind(s) {
      if (s instanceof Mesh) {
        return "mesh";
      } else if (s instanceof Line) {
        return "line";
      } else {
        return "other";
      }
    }
After (js):
    let Three = require("three");

    function kind(s) {
      if (s instanceof Three.Mesh) {
        return "mesh";
      } else if (s instanceof THREE.Line) {
        return "line";
      } else {
        return "other";
      }
    }

Representation modified (where the class of an @instanceof type is found):
Before (representation): Ast_untagged_variants.process_runtime_annotation
    @instanceof("Mesh") ↦ the global Mesh
    @module("three") @instanceof("Mesh") ↦ the global Mesh
    @scope("THREE") @instanceof("Mesh") ↦ the global Mesh
    note: a class is identified by its path
After (representation): Ast_untagged_variants.class_of_attributes, Lam_compile_external_call.class_constructor
    @instanceof("Mesh") ↦ the global Mesh
    @module("three") @instanceof("Mesh") ↦ Three.Mesh, with Three the import of "three"
    @module("./shape.js") @instanceof("default") ↦ the default import of "./shape.js"
    @scope("THREE") @instanceof("Mesh") ↦ the global THREE.Mesh, as @instanceof("THREE.Mesh")
    @module("lib") @notundefined ↦ never undefined, @module ignored as before
    note: a class is identified by its path and its module

Diagnostic removed (two classes of one name in a variant):
Example:
    @instanceof("Mesh") type globalMesh
    @module("three") @instanceof("Mesh") type mesh

    @unboxed
    type t = Global(globalMesh) | Three(mesh) | Plain({"plain": bool})

    let kind = x =>
      switch x {
      | Global(_) => "global"
      | Three(_) => "three"
      | Plain(_) => "plain"
      }
Before (diagnostic):
    This untagged variant definition is invalid: At most one case can be an instance of Mesh.
After (js):
    let Three = require("three");

    function kind(x) {
      if (x instanceof Mesh) {
        return "global";
      } else if (x instanceof Three.Mesh) {
        return "three";
      } else {
        return "plain";
      }
    }

Diagnostic added (an interface that states another module):
Example:
    module M: {
      @module("three") @instanceof("Mesh") type mesh
    } = {
      @instanceof("Mesh") type mesh
    }
Before (diagnostic): none, both declarations stated the global Mesh
After (diagnostic):
    Signature mismatch:

    Actual declaration (Example.res:4:23-31):
      @instanceof("Mesh") type mesh

    Expected declaration (Example.res:2:40-48):
      @module("three") @instanceof("Mesh") type mesh

    Their runtime representations differ:
      Actual declaration: instances of Mesh
      Expected declaration: instances of Mesh from "three"

Diagnostic modified (an @instanceof payload that is not a string):
Example:
    @module("three") @instanceof(Mesh) type mesh
Before (diagnostic):
    @instanceof expects the name of a global class, such as @instanceof("Date") or @instanceof("Intl.Locale").
After (diagnostic):
    @instanceof expects the name of a class that "three" exports, such as @instanceof("Mesh"), or @instanceof("default") for its default export.

Diagnostic added (a @scope that cannot lead to a class):
Example:
    @scope("default") @instanceof("Mesh") type mesh
Before (diagnostic): none, @scope was ignored and the check read the global Mesh
After (diagnostic):
    Without @module, the first property of @scope is a global, which cannot be named like the keyword "default".

Diagnostic added (a @module that names no module):
Example:
    @module(("three", "THREE")) @instanceof("Mesh") type mesh
Before (diagnostic): none, @module was ignored and the check read the global Mesh
After (diagnostic):
    @module on an @instanceof type expects the module that exports the class, such as @module("three") or @module("./shapes.js").

Review: Why are @module and @scope still ignored on a @typeof or @notundefined type? @notundefined shipped in v12, so an error there would break bindings that compile today, and without a class the attributes cannot make a check read the wrong value, which was the harm in #9239.
Review: Where is a relative path such as @module("./x.js") resolved? It is emitted as written, relative to the module that compiles the check, as for a @module external used from another module.
Review: Why does a class of a module skip the checks of global paths such as Object or Array? Those name the builtin classes only as globals; an export can be named anything, also like a keyword such as default.

Fixes: #9239
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Tsnobiladzé <2479216+tsnobip@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Changelog

💥 Breaking Change

  • @module and @scope on a type declaration without @instanceOf are an
    error. They had no effect there; remove them.

🐛 Bug fix

  • Read the class of an @instanceOf type from its module with @module("m"),
    importing it as a @module external does, and through the properties of
    @scope. Both were silently ignored, so the check read a global of the
    class's name.

Semantic Diff

3 commits · Full page

Read the class of an @instanceOf type from its @module and @scope

e13e98e · tsnobip + Claude · Nov 15, 2026, 17:43 UTC

Why

@module and @scope on an @instanceOf type were silently ignored (#9239), so the class check of an untagged variant read a global of the class's name. For a class of a JavaScript library or a local file that global does not exist, and the check threw a ReferenceError. Like an external, the type now says where its class is found: @module("m") reads it among the exports of m, "default" for the default export, imported as a @module external imports it, and @scope puts its properties in front of the path.

JS modified (class check of an @instanceOf type)

@instanceOf("Object3D") type object3D
@module("three") @instanceOf("Mesh") type mesh = private object3D
@scope("THREE") @instanceOf("Line") type line = private object3D

@unboxed
type shape = Mesh(mesh) | Line(line) | Other(object3D)

let kind = s =>
  switch s {
  | Mesh(_) => "mesh"
  | Line(_) => "line"
  | Other(_) => "other"
  }

js

+let Three = require("three");
+
 function kind(s) {
-  if (s instanceof Mesh) {
+  if (s instanceof Three.Mesh) {
     return "mesh";
-  } else if (s instanceof Line) {
+  } else if (s instanceof THREE.Line) {
     return "line";
   } else {
     return "other";
   }
 }

Representation modified (where the class of an @instanceOf type is found)

representation · Before: Ast_untagged_variants.process_runtime_annotation · After: Ast_untagged_variants.class_of_attributes, Lam_compile_external_call.class_constructor

 @instanceOf("Mesh")                          ↦ the global Mesh
-@module("three") @instanceOf("Mesh")         ↦ the global Mesh
-@scope("THREE") @instanceOf("Mesh")          ↦ the global Mesh
-note: a class is identified by its path
+@module("three") @instanceOf("Mesh")         ↦ Three.Mesh, with Three the import of "three"
+@module("./shape.js") @instanceOf("default") ↦ the default import of "./shape.js"
+@scope("THREE") @instanceOf("Mesh")          ↦ the global THREE.Mesh, as @instanceOf("THREE.Mesh")
+@module("lib") @notUndefined                 ↦ never undefined, @module ignored as before
+note: a class is identified by its path and its module

Diagnostic removed (two classes of one name in a variant)

@instanceOf("Mesh") type globalMesh
@module("three") @instanceOf("Mesh") type mesh

@unboxed
type t = Global(globalMesh) | Three(mesh) | Plain({"plain": bool})

let kind = x =>
  switch x {
  | Global(_) => "global"
  | Three(_) => "three"
  | Plain(_) => "plain"
  }

diagnostic · Before

This untagged variant definition is invalid: At most one case can be an instance of Mesh.

js · After

let Three = require("three");

function kind(x) {
  if (x instanceof Mesh) {
    return "global";
  } else if (x instanceof Three.Mesh) {
    return "three";
  } else {
    return "plain";
  }
}

Diagnostic added (an interface that states another module)

module M: {
  @module("three") @instanceOf("Mesh") type mesh
} = {
  @instanceOf("Mesh") type mesh
}

diagnostic

-none, both declarations stated the global Mesh
+Signature mismatch:
+
+Actual declaration (Example.res:4:23-31):
+  @instanceOf("Mesh") type mesh
+
+Expected declaration (Example.res:2:40-48):
+  @module("three") @instanceOf("Mesh") type mesh
+
+Their runtime representations differ:
+  Actual declaration: instances of Mesh
+  Expected declaration: instances of Mesh from "three"

Diagnostic modified (an @instanceOf payload that is not a string)

@module("three") @instanceOf(Mesh) type mesh

diagnostic

-@instanceOf expects the name of a global class, such as @instanceOf("Date") or @instanceOf("Intl.Locale").
+@instanceOf expects the name of a class that "three" exports, such as @instanceOf("Mesh"), or @instanceOf("default") for its default export.

Diagnostic added (a @scope that cannot lead to a class)

@scope("default") @instanceOf("Mesh") type mesh

diagnostic

-none, @scope was ignored and the check read the global Mesh
+Without @module, the first property of @scope is a global, which cannot be named like the keyword "default".

Diagnostic added (a @module that names no module)

@module(("three", "THREE")) @instanceOf("Mesh") type mesh

diagnostic

-none, @module was ignored and the check read the global Mesh
+@module on an @instanceOf type expects the module that exports the class, such as @module("three") or @module("./shapes.js").

Review

  • Why are @module and @scope still ignored on a @typeOf or @notUndefined type? @notUndefined shipped in v12, so an error there would break bindings that compile today, and without a class the attributes cannot make a check read the wrong value, which was the harm in @module on an @instanceOf type is silently ignored #9239.
  • Where is a relative path such as @module("./x.js") resolved? It is emitted as written, relative to the module that compiles the check, as for a @module external used from another module.
  • Why does a class of a module skip the checks of global paths such as Object or Array? Those name the builtin classes only as globals; an export can be named anything, also like a keyword such as default.
Test the tuple @scope and the remaining @instanceOf payload errors

2b4c744 · tsnobip + Claude · Nov 15, 2026, 18:07 UTC

Codecov's patch report on #9309 listed 10 uncovered lines in ast_untagged_variants.ml. Five were real gaps, now tested: the tuple form of @scope (the runtime test reads a class through two properties), a @scope with a non-string or no payload, @module(""), and a non-string @instanceOf without @module. The other five were covered but not measurable. The @scope errors went through a helper that always raises, so bisect never reached the point after the call; they now raise directly. The fallback for attributes without a location, which source code never reaches, is now one shared function instead of three copies.

✨ Reject @module and @scope on a type without @instanceOf

3dcad0a · tsnobip + Claude · Nov 16, 2026, 07:57 UTC · new

Why

@module and @scope on a type declaration without @instanceOf had no effect and were ignored without a word. The same silence on an @instanceOf type is how #9239 went unnoticed. Now that the two attributes say where the class of an @instanceOf type is found, they are an error on any other type, as suggested in the review of #9309.

Diagnostic added (@module or @scope on a type without @instanceOf)

@module("three") type mesh
@scope("THREE") @notUndefined type line
@module("x") type record = {a: int}

diagnostic · After: one error per declaration, each compiled alone

-none, the attributes were ignored
+@module on a type declaration names the module a class is imported from, so it needs @instanceOf too. Add @instanceOf with the name of the class, or remove @module.
+@scope on a type declaration names the properties a class is read through, so it needs @instanceOf, and this type has @notUndefined instead. Remove @scope, or write @instanceOf instead of @notUndefined if its values are instances of a class.
+@module on a type declaration names the module a class is imported from, so it needs @instanceOf, which only abstract types and type abbreviations can have. Remove @module.

The advice depends on the declaration, since adding @instanceOf only works on an abstract type or an abbreviation without another annotation. A record with both @typeOf and @module still reports the misplaced @typeOf first. The @instanceOf completion doc no longer calls the class global, since it can come from a module.

⚠️ Breaking: @module or @scope on a type declaration without @instanceOf no longer compiles. They never had an effect there: remove them.

Review

  • Does an interface compiled by an older compiler still load? Yes: the check runs in Typedecl.transl_declaration, where a declaration is type-checked, and process_runtime_annotation, which also reads declarations from .cmi files, does not raise it.

@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.63780% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.09%. Comparing base (a531dc3) to head (3dcad0a).

Files with missing lines Patch % Lines
tests/ounit_tests/ounit_string_literal_tests.ml 71.42% 2 Missing ⚠️
compiler/ml/ast_untagged_variants.ml 98.78% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9309      +/-   ##
==========================================
+ Coverage   82.06%   82.09%   +0.02%     
==========================================
  Files         455      455              
  Lines       65399    65493      +94     
==========================================
+ Hits        53672    53765      +93     
- Misses      11727    11728       +1     
Files with missing lines Coverage Δ
compiler/core/js_exp_make.ml 66.47% <ø> (-0.30%) ⬇️
compiler/core/lam_compile.ml 90.42% <100.00%> (+0.02%) ⬆️
compiler/core/lam_compile_external_call.ml 93.14% <100.00%> (+0.16%) ⬆️
compiler/ml/predef.ml 100.00% <100.00%> (ø)
compiler/ml/typedecl.ml 83.60% <100.00%> (+0.06%) ⬆️
compiler/ml/variant_runtime.ml 93.54% <100.00%> (+0.44%) ⬆️
tests/ounit_tests/ounit_untagged_dispatch_tests.ml 94.93% <100.00%> (+0.53%) ⬆️
compiler/ml/ast_untagged_variants.ml 88.01% <98.78%> (+3.74%) ⬆️
tests/ounit_tests/ounit_string_literal_tests.ml 90.62% <71.42%> (-0.11%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 640,952,301 → 640,986,911 (+0.01%).

Generated projects: 920,898,990 → 920,932,012 (±0.00%).

Benchmark Base Head Change
packages/@rescript/runtime/Dom.res 1,068,580 1,071,435 +0.27%
packages/@rescript/runtime/Primitive_js_extern.res 239,405 239,695 +0.12%
packages/@rescript/runtime/Stdlib_Intl_RelativeTimeFormat.res 179,823 180,006 +0.10%
packages/@rescript/runtime/Stdlib_Intl_ListFormat.res 169,182 169,352 +0.10%

Instructions

In total: 9,209,714,195 → 9,209,211,371 (-0.01%).

Benchmark Base Head Change
packages/@rescript/runtime/Stdlib_Math.resi 21,221,646 21,192,812 -0.14%
packages/@rescript/runtime/Stdlib_Temporal_PlainDate.res 24,023,764 23,998,733 -0.10%
packages/@rescript/runtime/Stdlib_List.resi 24,554,466 24,528,929 -0.10%

Output size

In total: 25,843,406 → 25,848,367 (+0.02%).

Benchmark Base Head Change
output/playground/compiler.js 1,889,883 1,894,445 +0.24%

Pull request 3dcad0a compared with base a531dc3 in this run.

@tsnobip

tsnobip commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T18:04:26.250703Z e13e98e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@9309

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@9309

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@9309

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@9309

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@9309

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@9309

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@9309

commit: 3dcad0a

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: e13e98ed62

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown

Codecov's patch report on #9309 listed 10 uncovered lines in
`ast_untagged_variants.ml`. Five were real gaps, now tested: the tuple
form of `@scope` (the runtime test reads a class through two properties),
a `@scope` with a non-string or no payload, `@module("")`, and a
non-string `@instanceOf` without `@module`. The other five were covered
but not measurable. The `@scope` errors went through a helper that always
raises, so bisect never reached the point after the call; they now raise
directly. The fallback for attributes without a location, which source
code never reaches, is now one shared function instead of three copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Tsnobiladzé <2479216+tsnobip@users.noreply.github.com>
@cknitt

cknitt commented Nov 15, 2026

Copy link
Copy Markdown
Member

Suggestion: make @module or @scope on a type without @instanceOf an error instead of ignoring it.

Silently ignoring these attributes is how #9239 went unnoticed. Code that breaks only has an attribute that never did anything, and the fix is to remove it. That seems fine for v13, even though it's technically breaking. #9308 had this as @module on a type declaration names the module a class is imported from, so it needs @instanceOf too (and @scope has no effect on a type declaration).

It could also be a small follow-up PR after this one, if you'd rather keep this PR non-breaking.

@cknitt

cknitt commented Nov 15, 2026

Copy link
Copy Markdown
Member

Follow-up idea, separate from this PR: parse @scope in one place for externals and @instanceOf types.

This PR checks a class's @scope carefully: a non-empty list of strings, and without @module, a first scope that isn't a keyword. Externals don't check the first scope, so they emit broken JS today:

@scope("class") @val external b: int = "b"
@scope("foo-bar") @val external d: int = "d"
class.b     // syntax error
foo-bar.d   // runs as foo - bar.d

A shared parser in Ast_payload could take over strings_of_payload and these checks, and ast_external_process would use it too. Two rules would stay class-only:

  • every segment is an identifier, since the class path is a dotted string;
  • no globalThis prefix, since it would give one class two identities. @scope("globalThis") is common and valid on externals.

For externals this is a bug fix that only breaks code already emitting broken JS, so it would get its own PR and changelog entry.

Why:
    `@module` and `@scope` on a type declaration without `@instanceOf` had
    no effect and were ignored without a word. The same silence on an
    `@instanceOf` type is how #9239 went unnoticed. Now that the two
    attributes say where the class of an `@instanceOf` type is found, they
    are an error on any other type, as suggested in the review of #9309.

Diagnostic added (@module or @scope on a type without @instanceof):
Example:
    @module("three") type mesh
    @scope("THREE") @notundefined type line
    @module("x") type record = {a: int}
Before (diagnostic): none, the attributes were ignored
After (diagnostic): one error per declaration, each compiled alone
    @module on a type declaration names the module a class is imported from, so it needs @instanceof too. Add @instanceof with the name of the class, or remove @module.
    @scope on a type declaration names the properties a class is read through, so it needs @instanceof, and this type has @notundefined instead. Remove @scope, or write @instanceof instead of @notundefined if its values are instances of a class.
    @module on a type declaration names the module a class is imported from, so it needs @instanceof, which only abstract types and type abbreviations can have. Remove @module.

The advice depends on the declaration, since adding `@instanceOf` only
works on an abstract type or an abbreviation without another annotation.
A record with both `@typeOf` and `@module` still reports the misplaced
`@typeOf` first. The `@instanceOf` completion doc no longer calls the class
global, since it can come from a module.

Review: Does an interface compiled by an older compiler still load? Yes: the check runs in `Typedecl.transl_declaration`, where a declaration is type-checked, and `process_runtime_annotation`, which also reads declarations from .cmi files, does not raise it.

Breaking: `@module` or `@scope` on a type declaration without `@instanceOf` no longer compiles. They never had an effect there: remove them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Tsnobiladzé <2479216+tsnobip@users.noreply.github.com>

@cknitt cknitt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@tsnobip
tsnobip merged commit 54b923a into master Nov 16, 2026
22 checks passed
@tsnobip
tsnobip deleted the module-instanceof branch November 16, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@module on an @instanceOf type is silently ignored

2 participants