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

element.firstElementChild() doesn't cause an error #112

Open
Harbs opened this issue Jan 21, 2020 · 9 comments
Open

element.firstElementChild() doesn't cause an error #112

Harbs opened this issue Jan 21, 2020 · 9 comments
Assignees
Labels

Comments

@Harbs
Copy link
Contributor

Harbs commented Jan 21, 2020

firstElementChild is of type Element and I'd expect trying to call it as a function would cause a compiler error call to type is not a function. but it compiles with no error.

This is the full statement which doesn't get an error:
element.insertBefore(indicator.element,element.firstElementChild());
element and indicator.element are both of type org.apache.royale.core.WrappedHTMLElement

@Harbs
Copy link
Contributor Author

Harbs commented Jan 21, 2020

Actually, it looks like this is a global problem.

I just picked EdgeData (because it's a simple class) and added this.bottom() in the constructor and no error. If I add private var foo:String to the class, there is an error, so it looks to me like a getter passes the function check, but a simple var doesn't.
@aharui @joshtynjala Thoughts?

@joshtynjala
Copy link
Member

Confirmed that them Royale compiler does not produce a compile-time error when attempting to call a getter or setter as a function.

The Flex SDK produces the following compiler error:

Error: Call to a possibly undefined method foo through a reference with static type MyClass.

@joshtynjala joshtynjala self-assigned this Jan 21, 2020
asfgit pushed a commit that referenced this issue Jan 21, 2020
…etter as a function and produces the same error as attempting to call a variable (references #112)

Similar to the variable, this currently applies to primitive types only (like Number, Boolean, int, uint, and String).
@joshtynjala
Copy link
Member

joshtynjala commented Jan 21, 2020

Update. I've determined that there are actually two issues here.

  1. Attempting to call a getter/setter as a function isn't producing a compiler error.
  2. Attempting to call a variable as a function, if the type is anything other than Number/Boolean/String/int/uint isn't producing a compiler error. (no error should result from a variable of type Function, Class, Object, or *, of course)

The Flex SDK produces a compiler error in both cases.

@aharui
Copy link
Contributor

aharui commented Jan 21, 2020

The commit looked like it was only for case 1 (getter/setter)?

@joshtynjala
Copy link
Member

Correct. Another commit is on the way soon.

@aharui
Copy link
Contributor

aharui commented Jan 21, 2020

It may be too early in the morning for me, but are you sure that the error shouldn't also be added for type Class? And what about XML and instances of classes?

Bonus if you can output a warning for type Object and type *

@joshtynjala
Copy link
Member

joshtynjala commented Jan 21, 2020

I checked the Flex SDK, and it does not output any errors or warnings when calling a variable of type Function, Class, Object, or * as a function.

If the variable has any other type, there's an error (at least for the types that I tested, which included XML and custom classes)

@joshtynjala
Copy link
Member

I've determined that the Royale compiler used to be as strict as the Flex SDK compiler. However, it was made more lenient in commit 1152253. It seems that we needed a hack to allow jquery's $ to expose its own methods and also be called as a function.

@aharui
Copy link
Contributor

aharui commented Jan 21, 2020

Well, if you have time, you are welcome to restore the old code and come up with a different solution for the JQuery issue.

One possibility is that we should create a way to mark a typedef as "dynamic" (if there isn't already a way I didn't know about) which I think JQuery is.

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

No branches or pull requests

3 participants