winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.99k stars 196 forks source link

`unexpected "identifier"` with enums #6071

Open eladb opened 6 months ago

eladb commented 6 months ago

I tried this:

enum StreamViewType {
  /**
    * The entire item, as it appears after it was modified, is written to the stream.
    */
  NEW_IMAGE = "NEW_IMAGE",
  /**
    * The entire item, as it appeared before it was modified, is written to the stream.
    */
  OLD_IMAGE = "OLD_IMAGE",
  /**
    * Both the new and the old item images of the item are written to the stream.
    */
  NEW_AND_OLD_IMAGES = "NEW_AND_OLD_IMAGES",
  /**
    * Only the key attributes of the modified item are written to the stream.
    */
  KEYS_ONLY = "KEYS_ONLY"

}

This happened:

an error has occurred:
Failed to compile.

error: Unexpected 'identifier'
  --> wing/main.w:1:6
  |
1 | enum StreamViewType {
  |      ^^^^^^^^^^^^^^ Unexpected 'identifier'

error: Unexpected 'comment'
  --> wing/main.w:2:3
  |  
2 | /   /**
3 | |     * The entire item, as it appears after it was modified, is written to the stream.
4 | |     */
  | \------^ Unexpected 'comment'

error: Unexpected 'identifier'
  --> wing/main.w:5:3
  |
5 |   NEW_IMAGE = "NEW_IMAGE",
  |   ^^^^^^^^^ Unexpected 'identifier'

error: Unexpected 'identifier'
  --> wing/main.w:5:16
  |
5 |   NEW_IMAGE = "NEW_IMAGE",
  |                ^^^^^^^^^ Unexpected 'identifier'

error: Unexpected 'string'
  --> wing/main.w:5:25
  |  
5 |     NEW_IMAGE = "NEW_IMAGE",
  | /-------------------------^
6 | |   /**
7 | |     * The entire item, as it appeared before it was modified, is written to the stream.
8 | |     */
9 | |   OLD_IMAGE = "OLD_IMAGE",
  | \---------------^ Unexpected 'string'

error: Unexpected 'identifier'
  --> wing/main.w:9:16
  |
9 |   OLD_IMAGE = "OLD_IMAGE",
  |                ^^^^^^^^^ Unexpected 'identifier'

error: Unexpected 'string'
   --> wing/main.w:9:25
   |  
 9 |     OLD_IMAGE = "OLD_IMAGE",
   | /-------------------------^
10 | |   /**
11 | |     * Both the new and the old item images of the item are written to the stream.
12 | |     */
13 | |   NEW_AND_OLD_IMAGES = "NEW_AND_OLD_IMAGES",
   | \------------------------^ Unexpected 'string'

error: Unexpected 'identifier'
   --> wing/main.w:13:25
   |
13 |   NEW_AND_OLD_IMAGES = "NEW_AND_OLD_IMAGES",
   |                         ^^^^^^^^^^^^^^^^^^ Unexpected 'identifier'

error: Unexpected 'string'
   --> wing/main.w:13:43
   |  
13 |     NEW_AND_OLD_IMAGES = "NEW_AND_OLD_IMAGES",
   | /-------------------------------------------^
14 | |   /**
15 | |     * Only the key attributes of the modified item are written to the stream.
16 | |     */
17 | |   KEYS_ONLY = "KEYS_ONLY"
   | \---------------^ Unexpected 'string'

error: Unexpected 'identifier'
   --> wing/main.w:17:16
   |
17 |   KEYS_ONLY = "KEYS_ONLY"
   |                ^^^^^^^^^ Unexpected 'identifier

I expected this:

To give me a nicer error indicating enums syntax is currently different or to work?

Is there a workaround?

No response

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

github-actions[bot] commented 3 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!