Language related - issues

island
oxygene

(SH) #1

Hi,

here I will post from now on just Language related issues:

  1. E0: internal Error reference not set to an instance of an object (in require section)
  2. E0: internal error: Unknown typeID for System.NamedTuples
  3. C-like memory allocation within a record (still) doesnt work, but when the type is class, it works!
  4. Exception with a message in constructor, doesnt show in the Exception-GUI

–Shpend


(Carlo Kok) #2

I’m going to need that shows these issues to be able to fix them. (Except for the last one).


(RemObjects) #3

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


(SH) #4

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);

(SH) #5

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


(SH) #6

just in case I am not specific enough:


(Carlo Kok) #7

(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.


(SH) #8

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!


(Carlo Kok) #9

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


(marc hoffman) #10

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


(SH) #11

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?


(marc hoffman) #12

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


(Carlo Kok) #13

@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.


(Carlo Kok) #14

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


(RemObjects) #15

bugs://79714 got closed with status fixed.


(SH) #16

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)


(Carlo Kok) #17

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.

(SH) #18

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`?


(Carlo Kok) #19

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


(SH) #20

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…