Re: Delphi 10.3 run button leads to strange compile/build failure

Skybuck Flying <[email protected]> Fri, 13 Jan 2023 08:23:47 -0800 (PST)
Newsgroups alt.comp.lang.borland-delphi
Message-ID <[email protected]>
I forgot to include some more context:

The original V5 leading to these strange build errors:

// "for internal use only", it's necessary:
// moved to interface section to solve following problem:
// [dcc32 Error] Unit_TrySetLength_version_005.pas(498):
// E2506 Method of parameterized type declared in interface section must not use
// local symbol 'WrapperDynArraySetLength'
procedure WrapperDynArraySetLength( var Para; typeInfo: Pointer; dimCnt: NativeInt; lengthVec: PNativeint);

// Skybuck: Use a little bit of "generic" and "typeinfo" "compiler magic ???", idea to use generics and class wrapper from ChatGPT feedback/session/answer, ChatGPT = AI from OpenAI. User "aer4af" from PascalCoin Discord chatted with ChatGPT and repeated my questions for ChatGPT.
type
	EDimensionCountException = class(Exception);

	TTrySetLengthHelper = class
		class function TrySetLengthV5<ParameterType>
		(
			var ParaVar : ParameterType; const ParaLengthArray: array of integer
//			var ParaVar : ParameterType; ParaLengthArray: array of integer
		) : boolean;
	end;

The new V6, which solves the build errors apperently, but it's less nice because it requires passing a type-parameter to the class, so it leads to more typing:

// problem no longer present in V6 ?
// conclusion: maybe type-parameterized methods are buggy in Delphi 10.3:
// apperently: type-parameterized classes less/not buggy.
procedure WrapperDynArraySetLength( var Para; typeInfo: Pointer; dimCnt: NativeInt; lengthVec: PNativeint);

// Skybuck: Use a little bit of "generic" and "typeinfo" "compiler magic ???", idea to use generics and class wrapper from ChatGPT feedback/session/answer, ChatGPT = AI from OpenAI. User "aer4af" from PascalCoin Discord chatted with ChatGPT and repeated my questions for ChatGPT.
type
	EDimensionCountException = class(Exception);

	// Less nice, needs more typing, try use V5 instead ! see unit version_005.
	TTrySetLengthHelper<ParameterType> = class
		class function TrySetLengthV6
		(
			var ParaVar : ParameterType; const ParaLengthArray: array of integer
//			var ParaVar : ParameterType; ParaLengthArray: array of integer
		) : boolean;
	end;

Usage example for v6, plus it also needs explicit types to work, I guess now I know what Delphi means with it... hehe...:

type
	TArrayOfArrayOfArrayOfInteger = array of array of array of array of integer; // explicit type...
var
	vIntegerArray : TArrayOfArrayOfArrayOfInteger;
	if TTrySetLengthHelper<TArrayOfArrayOfArrayOfInteger>.TrySetLengthV6( vIntegerArray, [100,200,300,1] ) then

Bye for now,
  Skybuck.