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

Interaction of extended attributes and typedefs is weird #649

Open
bzbarsky opened this issue Feb 23, 2019 · 4 comments
Open

Interaction of extended attributes and typedefs is weird #649

bzbarsky opened this issue Feb 23, 2019 · 4 comments

Comments

@bzbarsky
Copy link
Collaborator

Consider this IDL:

    typedef [Clamp] long ClampedLong;

    interface Bar {
      void func(ClampedLong arg);
    };

Is this valid IDL? Per https://heycam.github.io/webidl/#idl-type-extended-attribute-associated-with step 6, the extended attributes "associated with" ClampedLong include [Clamp]. But https://heycam.github.io/webidl/#Clamp says:

A type that is not an integer type must not be associated with the [Clamp] extended attribute.

and ClampedLong is not an "integer type" in the sense linked here, as far as I can tell...

Presumably the intent is to allow this, right? That should be made clearer.

@bzbarsky
Copy link
Collaborator Author

@domenic

@bzbarsky
Copy link
Collaborator Author

Also, is this allowed?

typedef long Foo;

interface Bar {
  void func([Clamp] Foo arg);
};

https://heycam.github.io/webidl/#idl-typedefs says no extended attributes apply to typedefs, but presumably that means the actual typedef statement, right? So in this case, does the arg get clamping behavior?

@domenic
Copy link
Member

domenic commented Feb 25, 2019

Dang, I'd hoped given that one of the points in my OP of #286 was about interaction with typedefs, that we'd nailed this the first time around. OK, let me try to reload this into my brain...

and ClampedLong is not an "integer type" in the sense linked here, as far as I can tell...

It seems like it should be an integer type. Simpler, it seems to me that given typedef long Long, then Long should be an integer type.

https://heycam.github.io/webidl/#idl-typedefs says no extended attributes apply to typedefs, but presumably that means the actual typedef statement, right?

Right, that was definitely the intent there. I guess it should instead say something like

Although it is allowed in the grammar, no extended attributes apply to typedef declarations themselves. (But, the type being given a new name might itself include extended attributes.)

So in this case, does the arg get clamping behavior?

It seems like it should, right? The typedef should be transparent, ideally. https://heycam.github.io/webidl/#idl-type-extended-attribute-associated-with seems to do the right thing, so I guess this is just about whether Foo is an integer type again?

@bzbarsky
Copy link
Collaborator Author

It seems like it should be an integer type

That would be ideal; it just doesn't seem to be what the spec says right now.

The typedef should be transparent, ideally

I agree.

so I guess this is just about whether Foo is an integer type again

Hmm. Yes, I think so...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants