BBx-Kitchen / bbj-language-server

BBj Language Server
MIT License
7 stars 6 forks source link

Using undefined class fields should produce an error #80

Open hyyan opened 1 year ago

hyyan commented 1 year ago

The following sample utilizes the #window! field, which is not defined in the class. However, no errors or warnings are displayed, but there should be an error notification.

class public Test
  method public void run(BBjWindow window!)
    ? #window!
  methodend
classend

Note if I remove the method parameter then a warning is shown.

class public Test
  method public void run()
    ? #window!
  methodend
classend
dhuebner commented 1 year ago

@hyyan

Note if I remove the method parameter then a warning is shown.

Thanks for reporting! Yeah, currently we link to the parameter BBjWindow window!.

Is accessing the fields without an # valid, I don't recall it? Would following work in BBj?

class public Test
  field private BBjWindow window!

  method public void run()
    ? window!
  methodend

classend
dhuebner commented 1 year ago

I'm not sure yet if it better to solve in linker or add a validation.

hyyan commented 1 year ago

Is accessing the fields without an # valid, I don't recall it?

No. it wont work

The special symbol # is required in front of a field name in order for a custom object method to get direct access to a field (bypassing the accessor methods)

https://documentation.basis.cloud/BASISHelp/WebHelp/tutorials/custom_objects/custom_objects_04fields.htm

dhuebner commented 1 year ago

Thank you for the link! I think the better way here is to add a validation.

StephanWald commented 1 year ago

stands for #this!.

Hence #window! references a field of the class, window! is a normal local variable in the method scope.