twinbasic / twinbasic

284 stars 23 forks source link

ActiveX DLL - Cannot assign Constant to a Public Enum in another Module #1441

Closed GCuser99 closed 1 year ago

GCuser99 commented 1 year ago

Describe the bug tB throws a compile error when I attempt to assign a constant to a public Enum value declared in another module.

To Reproduce Steps to reproduce the behavior:

  1. Open new ActiveX DLL project in tB
  2. Add MyClass.cls and MyModule.bas modules
  3. In MyModule.bas add the following declaration:
    Public Enum myConstants
    myA = 1
    myB = 2
    myC = 3
    End Enum
  4. In MyClass.cls, add the following declaration:
    Private Const mySomething As long = myConstants.myA

    tB indicates a compile error for myConstants.myA "[myConstants] does not contain 'myA' or is inaccessible in this context"

Expected behavior This should behave similar to VBA and compile.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop: OS: Windows 11 Excel 365 (64-bit) twinBASIC compiler version IDE Beta 201

Additional context Excel VBA allows the above without error. Additionally, if I make the following change in MyClass.cls:

'Private Const mySomething As long = myConstants.myA
Private mySomething As long = myConstants.myA

tB will not throw a compile error.

fafalone commented 1 year ago

For reference VB6 allows this as well. Also applies regardless of project type or whether it's .twin instead, or whether the const is placed in a class or module, or whether it's public or private.

WaynePhillipsEA commented 1 year ago

Fixed in BETA 221. Thanks!