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

Calling an undefined constructor via new is a warning, not an error. VM should be fixed. #3801

Closed
gbracha opened this issue Jun 20, 2012 · 3 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Milestone

Comments

@gbracha
Copy link
Contributor

gbracha commented Jun 20, 2012

See issue #1031.

Latest version of spec, section 10.10.1 replaces errors with warnings in cases where the class or the constructor is undeclared. Motivation is similar to other cases: do not impose workflow - just warn and make it a dynamic error.

"Let e be a new expression of the form new T.id(a1, .., an, xn+1: an+1, …, xn+k: an+k) or the form new T(a1, .., an, xn+1: an+1, …, xn+k: an+k). It is a static warning if T is not a class or interface accessible in the current scope, optionally followed by type arguments.

If e is of the form new T.id(a1, .., an, xn+1: an+1, …, xn+k: an+k) it is a static warning if T.id is not the name of a constructor declared by the type T. If e of the form new T(a1, .., an, xn+1: an+1, …, xn+k: an+k) it is a static warning if the type T does not declare a constructor with the same name as the declaration of T.
"

Consequently, it is a dynamic error to call such an undefined constructor:

"Evaluation of e proceeds as follows:

If T is not a class or interface accessible in the current scope, a dynamic error occurs. Otherwise, if q is not defined, a NoSuchMethodError is thrown. Otherwise, if q is a generative constructor (regardless of whether q is redirecting or not), then: ..."

@iposva-google
Copy link
Contributor

Set owner to @crelier.
Added Accepted label.

@crelier
Copy link
Contributor

crelier commented Sep 27, 2012

Added Started label.

@crelier
Copy link
Contributor

crelier commented Sep 27, 2012

Fixed at r12975.


Added Fixed label.

@gbracha gbracha added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Sep 27, 2012
@gbracha gbracha added this to the M1 milestone Sep 27, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants