apache / apache/grails-core

@GrailsCompileStatic(TypeCheckingMode.SKIP) is generating an Index 0 out of bounds for length 0 error

Open
#12,440 11 comments 0 reactions 0 assignees View on GitHub
info: no example attached type: bug
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Expected Behavior

My application was using Grails _5.1.2_ and I decided to update to Grails _5.1.4_ today.
The project is getting some errors related to **@GrailsCompileStatic(TypeCheckingMode.SKIP)**. On the previous version (_5.1.2_) was working as expected. I use this annotation on Controllers, Services and Domains.

this is the error **Index 0 out of bounds for length 0**

Any idea?

### Actual Behaviour

* What went wrong:
Execution failed for task ':compileGroovy'.
> BUG! exception in phase 'semantic analysis' in source unit '/Users/adrian/Sites/hulimotors/myapp/grails-app/controllers/myapp/RestaurantController.groovy' Index 0 out of bounds for length 0

![Screen Shot 2022-03-22 at 4 13 19 PM](https://user-images.githubusercontent.com/221474/159585809-cc2608e4-5dab-4dbe-922b-9bd308b1ba64.png)

### Steps To Reproduce

1. curl -O https://start.grails.org/myapp.zip -d profile=rest-api -d features=events,mongodb,security
2. cd myapp
3. grails create-domain-class Restaurant
4. grails generate-all myapp.Restaurant
5. Add new action method on the Controller

![Screen Shot 2022-03-22 at 4 13 37 PM](https://user-images.githubusercontent.com/221474/159585477-436b081d-7ede-4832-b185-8f01e6fb801b.png)

6. Add @GrailsCompileStatic to the Controller

![Screen Shot 2022-03-22 at 4 17 45 PM](https://user-images.githubusercontent.com/221474/159585576-40768aee-b23d-40f2-9bab-5b6275d9f8da.png)

.

### Environment Information

macOS Monterey
version 12.3

openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment Temurin-11.0.14+9 (build 11.0.14+9)
OpenJDK 64-Bit Server VM Temurin-11.0.14+9 (build 11.0.14+9, mixed mode)

### Example Application

_No response_

### Version

5.1.4

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported failure in myapp/grails-app/controllers/myapp/RestaurantController.groovy using the listed Grails 5.1.4 setup and @GrailsCompileStatic(TypeCheckingMode.SKIP). Compare compilation with Grails 5.1.2, focusing on the :compileGroovy semantic-analysis error. Done means the reproduction project compiles successfully with the annotation in place.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.