Opened 7 years ago
Closed 7 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: | 3.3.14.2 | Severity: | None |
Keywords: | Cc: |
Description
The code below illustrates the problem
#AutoIt3Wrapper_Run_Au3Check=N Global Const $tStruct = DllStructCreate("BYTE a") Works() Fails() Func Works($tStruct = $tStruct) $tStruct.a = 1 EndFunc Func Fails() $tStruct.a = 1 EndFunc
Output
"D:\Desktop\tmp.au3" (12) : ==> Cannot assign values to constants.: $tStruct.a = 1 ^ ERROR
Attachments (0)
Change History (5)
comment:1 Changed 7 years ago by Jos
comment:2 Changed 7 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 7 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") Works() Fails() Func Works($x = $tStruct) $x.a = 1 EndFunc Func Fails() $tStruct.a = 1 EndFunc
So $tStruct in Func works is not the Global declared one but a Local new variable.
Jos
comment:4 Changed 7 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 7 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.
M23
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.
What exactly is the issue with getting a warning when trying to change a constant?
Jos