Opened 6 years ago

Closed 6 years ago

#3581 closed Bug (Wont Fix)

Dot notation with DllStruct fails if the variable is a constant

Reported by: genius257 Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


The code below illustrates the problem

Global Const $tStruct = DllStructCreate("BYTE a")


Func Works($tStruct = $tStruct)
    $tStruct.a = 1

Func Fails()
    $tStruct.a = 1


"D:\Desktop\tmp.au3" (12) : ==> Cannot assign values to constants.:
$tStruct.a = 1

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by Jos

What exactly is the issue with getting a warning when trying to change a constant?


comment:2 Changed 6 years ago by genius257

I'm not changing the constant, but a property of the constant.
If it should fail, so should DllStructSetData($tStruct, "a", 1)

comment:3 Changed 6 years ago by Jos

The left $tStruct in Func Works() is a local declared variable for Func Works() and it act like doing it this way:

Global Const $tStruct = DllStructCreate("BYTE a")


Func Works($x = $tStruct)
    $x.a = 1

Func Fails()
    $tStruct.a = 1

So $tStruct in Func Works() is not the Global declared one but a Local new variable.


Last edited 6 years ago by Jos (previous) (diff)

comment:4 Changed 6 years ago by genius257

I can't seem to find any details about how a constant in AutoIt is treated other than the value of a constant cannot be changed.

But currently AutoIt allows properties to be changed in constant variables if for instance it's a DllStruct and DllStructSetData is used. This is like ES6 when defining a const with a object value. Properties of the object can still be changed. The only thing that's immutable is the binding source.

If AutoIt is not supposed to act like my example with ES6, then AutoIt should not allow DllStructSetData to work with a constatnt variable as it's first parimeter.

If on the other hand the ES6 example is the case, then AutoIt should allow properties of const variables to be changed when using dot notation.

I hope I've made myself understandable and that you see the current way it works is a bug one way or the other?

comment:5 Changed 6 years ago by Melba23

  • Resolution set to Wont Fix
  • Status changed from new to closed

Dot notation for structs is an undocumented feature and so bug reports about the feature are not supported. Use DllStructSetData instead.


Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.