Lucee doesn't show Filename and linenumbers on getComponentMetadata(InvalidComponent)

Description

GetComponentMetadata does not show error details when we try to get metadata of a component which has syntax errors. It wil fail with this error
lucee.transformer.bytecode.statement.ExpressionAsStatement cannot be cast to lucee.transformer.bytecode.statement.tag.TagComponent
Problem ONLY occurs when component definition is not on one line.
So

component {

is OK, but

component {

will fail. This is especially annoying in large projects using wirebox, since it is using getComponentMetaData all the time. It makes it almost impossible to track syntax errors.
Tools like cfformat will often break component definitions on multiple lines.

Description from LDEV-3955
This bug was discovered during this thread to find a solution to unrecognized dependent injection error in ColdBox:  https://community.ortussolutions.com/t/missing-dependency-error-with-wirebox-injection/9192/29

Essentially, there was a line in a dependency component that was being injected that looked like the following:

else if()

This really triggered a invalid syntax bytecode error, but due to the error being in an injected dependency, the reported error that popped up on the screen was a “requested missing dependency” error, while the dependency actually wasn’t missing in the first place – it was just trying to inject a component with an invalild syntax bytecode error.

I believe we should make a more descriptive error message for this situation.

Environment

None

Activity

Show:

Pothys - MitrahSoft 14 September 2020 at 15:37

I've added a test case for this ticket

Pull Request: https://github.com/lucee/Lucee/pull/1033

Pothys - MitrahSoft 14 September 2020 at 08:12

I've checked this ticket and confirmed the issue happened on lucee latest version 5.3.8.70_SNAPSHOT also.
yeah, if we use component with the same line of ( { ) is OK with a syntax error.
But, use component with the next line of ( { ) means, throws an error as per the reporter said.

Wil de Bruin 12 September 2020 at 19:49

https://github.com/wpdebruin/getComponentMetaData will show the problem in a small sample project

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 12 September 2020 at 19:46
Updated 20 May 2022 at 10:00

Flag notifications