Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comptime Emit issues #2116

Closed
disarray2077 opened this issue Jan 29, 2025 · 4 comments
Closed

Comptime Emit issues #2116

disarray2077 opened this issue Jan 29, 2025 · 4 comments

Comments

@disarray2077
Copy link
Contributor

disarray2077 commented Jan 29, 2025

The test project for the LuaTinker library only compiles if the following lines are present:

https://github.com/disarray2077/LuaTinker-Beef/blob/b7bb1d6f17c15b77f7d431ab2ca647ab981f45a5/src/Layers/Functor/Call_2.bf#L501-L512

This is the error I get when trying to compile the project without those lines:

ERROR: Unable to implicitly cast 'System.Span<char8>' to 'char8'
  while specializing method 'LuaTinker.Layers.CallLayer<System.String, "Split", false>(int L)' at line 2779:61 in $Emit$LuaTinker:LuaTinker.Layers
     var ret = func(StackHelper.Pop!<comptype(53)>(lua, 1), StackHelper.Pop!<comptype(84)>(lua, 2));
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > Error in emitted code at line 524:4 in d:\BeefLang\Repository\LuaTinker-Beef\src\Layers\Functor\Call_2.bf
    EmitCallLayer<T, const Name, const IsStatic>();
    ^^^^^^^^^^^^^
ERROR: Unable to implicitly cast 'System.StringView[]' to 'System.StringView'
  while specializing method 'LuaTinker.Layers.CallLayer<System.String, "Split", false>(int L)' at line 2926:61 in $Emit$LuaTinker:LuaTinker.Layers
     var ret = func(StackHelper.Pop!<comptype(53)>(lua, 1), StackHelper.Pop!<comptype(1032)>(lua, 2));
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > Error in emitted code at line 524:4 in d:\BeefLang\Repository\LuaTinker-Beef\src\Layers\Functor\Call_2.bf
    EmitCallLayer<T, const Name, const IsStatic>();
    ^^^^^^^^^^^^^
ERROR: Emitted code had errors
  while specializing method 'LuaTinker.Layers.CallLayer<System.String, "Split", false>(int L)' at line 524:4 in d:\BeefLang\Repository\LuaTinker-Beef\src\Layers\Functor\Call_2.bf
   EmitCallLayer<T, const Name, const IsStatic>();
   ^^^^^^^^^^^^^

Also, the "Emit" view sometimes doesn't expand, which can be a bit frustrating. I guess this is related to the error above.

reccc.mp4

Tested with: 9ae172c

@bfiete
Copy link
Collaborator

bfiete commented Jan 30, 2025

This was a little hard to debug so I added this:

public struct ComptypeStr
{
	Type mType;

	public this(Type t)
	{
		mType = t;
	}

	public override void ToString(String strBuffer)
	{
		strBuffer.AppendF($"comptype({mType.GetTypeId()})/*{mType}*/");
	}
}	

So instead of doing an AppendF of comptype({type.GetTypeId()}) you can do {ComptypeStr(type)}. Just an idea for debuggability.

There may be some additional investigation required for why 'comptype' was needed in some cases....

@bfiete
Copy link
Collaborator

bfiete commented Jan 30, 2025

It was a general type system issue with a collision of function params between params Span<uint8> and Span<uint8>

@bfiete bfiete closed this as completed Jan 30, 2025
@disarray2077
Copy link
Contributor Author

@bfiete Looks like there's still something wrong, the project doesn't compile anymore after the fix (439ae8d) because of the following link errors:

vdata.obj : error LNK2005: "public: static int bf::function_this_<struct bf::System::StringSplitEnumerator,class System::StringSplitEnumerator::String *,struct System::StringSplitEnumerator::Span<char> >::sBfTypeData" (?sBfTypeData@?$function_this_@UStringSplitEnumerator@System@bf@@PEAVString@12@U?$Span@D@12@@bf@@2HA) already defined in vdata.obj
vdata.obj : error LNK2005: "public: static int bf::function_this_<struct bf::System::StringStringSplitEnumerator,class System::StringStringSplitEnumerator::String *,class System::StringStringSplitEnumerator::Array1<struct bf::System::StringView> *>::sBfTypeData" (?sBfTypeData@?$function_this_@UStringStringSplitEnumerator@System@bf@@PEAVString@12@PEAV?$Array1@UStringView@System@bf@@@12@@bf@@2HA) already defined in vdata.obj

@bfiete
Copy link
Collaborator

bfiete commented Jan 31, 2025

Ah yeah, missed that. Another collision issue for the same thing except with mangling this time!

Fixed 717ce11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants