String Typed arrays are not validating types correctly

Description

If you used a typed array, it should ONLY allow that specific type as elements. This is not the case in Lucee.

 

test = arrayNew( 1, "String" ); test.append( "luis" ); test.append( javaCast( "int", 1 ) ); writedump(test);

 

That will be valid, and it should not allow int s into the string array. If you switch the type to numeric then it works.

Environment

None

Activity

Show:

Luis Majano 27 January 2023 at 12:26

I understand it’s type less and cfml assists on auto casting and inferring. But if you offer a language feature that makes an array generically typed it shouldn’t be Willy Nilly auto casting as pretty much almost everything can be casted to string in some capacity. It really renders the usability of a string typed array to an assuming implementation.

Anyways. I have said my peace.

Zac Spitzer 27 January 2023 at 09:43

I discussed with Mark from Adobe, he said they had similar internal discussions, but at the end of the day, cfml is typeless and everything is cast on demand to the expected type

https://github.com/lucee/Lucee/commit/fc3a4949ff7521cd4a10b4d5dc3cb85c6998654c

Pothys - MitrahSoft 19 January 2023 at 14:05

okay . I added a testcase to this ticket

will decide about this.


Pull Request: https://github.com/lucee/Lucee/pull/1937

Luis Majano 18 January 2023 at 13:16

I think that this doesn't seem right. If I asked for a strongly typed array, I don’t want any casting; that’s the whole point. If not, I don’t find a point in having a typed array where auto-casting is being done then.

Fixed

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 13 January 2023 at 12:05
Updated 27 January 2023 at 15:09
Resolved 27 January 2023 at 09:43

Flag notifications