Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Field needed by Interface is missing" has unknown position when defining from Context.defineType and then using Context.typeof #11754

Open
Speedphoenix opened this issue Aug 30, 2024 · 3 comments

Comments

@Speedphoenix
Copy link

Try haxe: https://try.haxe.org/#15BeB54A

  var pos = Context.currentPos();

  var tfields = (macro class {
    public var bit:Int;
  }).fields;

  var t:TypeDefinition = {
    pos: pos,
    pack: [],
    meta: [{name: ":structInit", pos: pos}],
    name: "TestType",
    kind: TDClass([{pack: [], name: "Test", sub: "TestInterface"},]),
    fields: tfields,
  };
  Context.defineType(t);
  var complex:ComplexType = TPath({pack: [], name: "Macro", sub: "TestType"});

  var type = Context.typeof(macro(null : $complex));

this yields

[ERROR] (unknown position)

   | Field bit2 needed by TestInterface is missing
@Simn
Copy link
Member

Simn commented Oct 16, 2024

This should fail in some way because you're trying to define a type that already exists, but the error message isn't ideal.

I misread that code, let me try again...

Edit: I can't tell what you're actually trying to do. To me it looks like the compiler is correct because your TestType class doesn't define bit2, only bit.

@kLabz
Copy link
Contributor

kLabz commented Oct 16, 2024

I think the issue here is just the lack of position for the error

@Simn
Copy link
Member

Simn commented Oct 16, 2024

Ah, I seem to struggle with reading comprehension today... This is indeed a bit silly because we don't necessarily know which type this is about.

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

No branches or pull requests

3 participants