Language related - issues

Thanks, logged as bugs://79714 (Message)

the 3 you know what I mean :wink: its in the project with the array, do you still have it?

the 2 you can easily reproduce, just do in the same project I sent you:

TCar = tuple of(price: int, color: byte, name:string);

btw:
would those named-tuples also be valuetyped ? thats important

just in case I am not specific enough:

(2) is fixed;
I need a testcase for 1

can you separate (3) from your project so I can see this in a simple file? I’ve never been able to reproduce it.

Cool thing, thank you!

TArray.pas (6.7 KB)

I hope it is sufficient, because the error occurs in the constructor of the module, and actually, you just need to replace the “class” keyword with “record” keyword

Ok, I testet it again in both projects(1 is just testing-stuff, 1 is handmadehero) and both compile fine with requires nearly everywhere :confused: I really could swear at some point in the code I got this E0, ok, nevermind, this is fine for now!

A post was split to a new topic: Implementation item should be limited in access

PLEASE stop recycling old threads for new bugs. Not sure how many more times i need to ask for this :(.

But the thread is called: “Language-related” and it is language related?

So you wish for each new bug, nevermind if he can be grouped, a new thread?

What’s the alternative? 2023, and we’re still posting new language issues for Oxygene 15 in bis thread, because they are “language related”?

@shpend_hoti I will miss stuff if you reuse threads. It’s also completely unclear what discussion belongs with what issue this way, and any bug report tracker reply won’t include which part of the thread it belongs to.

TArray.pas doesn’t compile on it’s own. Can you strip it of the things not needed?

bugs://79714 got closed with status fixed.

Ok, I will relate to that, thought just to save web-space, for bugs, which could be grouped, but ok, will regard this.

Ahh, yes, I forgot to attach “GLOBALS.pas”

here the both, this is the only dependency for TArray
TArray.zip (2.1 KB)

And make TArray<T> a record and then just new TArray(15) or something?

Tried that, seems fine. Also stripped it down (after being unable to reproduce the original issue) a lot:

namespace ConsoleApplication635;

interface
uses rtl;
type
  Program = class
  public

    class method Main(args: array of String): Int32;
    begin
      var lArray := new TArray<Byte>(15);
      writeLn('Ptr:'+IntPtr(lArray.first).ToString);
    end;

  end;

	type		
		[Packed]
		TItemState<T> = private record //use packed for array items, is more efficient 
			SwapedAt: IntPtr;
			DeletedAt: IntPtr;  	
			Origin: tuple of(IntPtr, T); 
		end;

		[Packed] 
		TBlock<T> = public record	
			Value: T;
			State: TItemState<T>;  	
		end;

		TArray<T> = public record		 		  
		private
			VOID := &default(T); readonly;
			fCount: IntPtr := 0;
			f_currentCapacity: IntPtr := 10;
			f_first: ^TBlock<T>; 
			method SetToDefault(const statePtr: ^TItemState<T>);
			
		public
			constructor(const cnt: IntPtr);
      property first: ^TBlock<T> read f_first;
						
		public invariants
				f_first <> nil;
				fCount <= f_currentCapacity;
			
		end;

	implementation
	
	method TArray<T>.SetToDefault(const statePtr: ^TItemState<T>);
	begin
		statePtr^.DeletedAt := -1;
		statePtr^.SwapedAt := -1;
		statePtr^.Origin := (-1, VOID);		
	end;

	constructor TArray<T>(const cnt: IntPtr);
	require
	  cnt > 0;
	begin		
		f_first := ^TBlock<T>(malloc(sizeOf(TBlock<T>) * cnt));
		SetToDefault(@f_first^.State);
		f_currentCapacity := cnt;
	end;

end.

So you get a valid f_first pointer, when TArray is record?

What value do you get from f_first? where does it point to`?

Yes. As you can see I even write it out. Seems like a valid pointer.

Wow, yes now I can see it, it works pretty fine, and you know what, this was I think the whole time a Debugger-Issue :joy: :joy:

Because, when you step into the code, you should see: f_first{0} as I do !

Happens…

I did fix the debugger so that it shows the proper values.

1 Like