Skip to content

Conversation

@aspizu
Copy link
Owner

@aspizu aspizu commented Jun 19, 2025

Summary

  • Adds compile-time validation for switch_costume and switch_backdrop blocks
  • Warns when costume/backdrop names don't exist, preventing runtime errors
  • Provides helpful guidance when file extensions are incorrectly included

Changes

  • Added InvalidCostumeName and InvalidBackdropName diagnostic types
  • Enhanced switch_costume validation against sprite's costume list
  • Enhanced switch_backdrop validation against stage's costume list (backdrops)
  • Cross-sprite backdrop validation: properly accesses stage from any sprite context
  • Helpful error messages with file extension guidance

Test plan

  • Validates invalid costume names in switch_costume blocks
  • Validates invalid backdrop names in switch_backdrop blocks
  • Shows helpful error messages with file extension guidance
  • Works from both stage and non-stage sprites
  • Existing tests pass with new validation errors caught

Example Output

error: costume 'dango' does not exist
--> main.gs:8:20
|
8 |     switch_costume "dango";
  |                    ^^^^^^^

error: backdrop 'dango' does not exist  
--> main.gs:11:21
|
11 |     switch_backdrop "dango";
   |                     ^^^^^^^

Closes #156

🤖 Generated with Claude Code

- Add InvalidCostumeName and InvalidBackdropName diagnostic types
- Validate costume names in switch_costume blocks against sprite costumes
- Validate backdrop names in switch_backdrop blocks against stage costumes
- Provide helpful error messages when file extensions are included
- Access stage backdrops from any sprite context for backdrop validation
- Classify both as compile-time errors to prevent runtime issues

Closes #156

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@aspizu aspizu merged commit a71d04c into main Jun 19, 2025
1 check passed
@aspizu aspizu deleted the feat/costume-backdrop-validation branch June 19, 2025 05:40
@faretek1
Copy link

does this incorrectly warn against 'previous costume' etc?

@aspizu
Copy link
Owner Author

aspizu commented Jun 19, 2025

you should use the previous/next blocks instead

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

warning when you write an invalid costume name (that doesn't exist), and help if you include the file extension

2 participants