BBx-Kitchen / bbj-language-server

BBj Language Server
MIT License
7 stars 6 forks source link

Validate field value against the type #79

Open hyyan opened 1 year ago

hyyan commented 1 year ago

Is it possible to validate field value against the type. The following should produce an error:

class public Test
  field public BBjNumber DrawerBreakpoint! = "(max-width: 800px)"
classend

The value is a string but the type is BBjNumber

dhuebner commented 1 year ago

@hyyan To fully support the type inference and validation we need a type system implementation. Implementing a type system is normally very time consuming. For simple or clear cases like above, we could provide a validation. Here we need to know that BBjNumber is a number type and a string literal is not convertible to a number.

What would probably help in some other cases is checking the variable name prefix, but for ! it will not work as java.lang.String is also an Object

hyyan commented 1 year ago

For simple or clear cases like above, we could provide a validation. Here we need to know that BBjNumber is a number type and a string literal is not convertible to a number.

What would probably help in some other cases is checking the variable name prefix, but for ! it will not work as java.lang.String is also an Object

@dhuebner That would be completely fine. We would like to cover only simple and obvious cases at the moment. Once we have a good understanding of the challenges involved, we can then start to work on more complex cases.