1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Fixes for type dependencies and tests for type deletion bug

This commit is contained in:
Brian Fiete 2020-06-04 11:47:55 -07:00
parent 198acef1c6
commit 03fbc9d468
16 changed files with 309 additions and 55 deletions

View file

@ -0,0 +1,5 @@
FileVersion = 1
[Project]
Name = "Bug"
StartupObject = "Bug.Program"

View file

@ -0,0 +1,6 @@
FileVersion = 1
Projects = {Bug = {Path = "."}}
[Workspace]
StartupProject = "Bug"

View file

@ -0,0 +1,21 @@
# This tests that types that fail generic tests don't create types referenced in methods
# and also that they get deleted immediately when they are dereferenced.
ShowFile("src/Program.bf")
SetExpectError("Generic argument")
Compile()
ExpectError()
AssertTypeInfo(1, "System.Collections.Dictionary<System.Collections.Dictionary<int, float>.Enumerator, (int key, float value)>", "Found Reified ValidateErrors")
AssertTypeInfo(1, "System.Collections.Dictionary<System.Collections.Dictionary<int, float>.Enumerator, (int key, float value)>.Entry", "Found Reified ValidateErrors")
ToggleCommentAt("Method3_BadCall")
ToggleCommentAt("Method3_GoodCall")
Compile()
AssertTypeInfo(0, "System.Collections.Dictionary<System.Collections.Dictionary<int, float>.Enumerator, (int key, float value)>", "")
AssertTypeInfo(0, "System.Collections.Dictionary<System.Collections.Dictionary<int, float>.Enumerator, (int key, float value)>.Entry", "")
AssertTypeInfo(0, "System.Collections.Dictionary<System.Collections.Dictionary<int, float>.Enumerator, (int key, float value)>", "")
AssertTypeInfo(0, "System.Collections.Dictionary<System.Collections.Dictionary<int, float>.Enumerator, (int key, float value)>.Entry", "")

View file

@ -0,0 +1,49 @@
#pragma warning disable 168
using System;
using System.Collections;
namespace Bug
{
class Program
{
class Dicto : Dictionary<int, float>
{
}
public static bool Method1<T>(IEnumerator<T> param1)
{
return true;
}
public static bool Method2<TEnumerator, TElement>(TEnumerator param1) where TEnumerator : IEnumerator<TElement>
{
for (let val in param1)
{
}
return true;
}
public static bool Method3<K, V>(Dictionary<K, V> param1) where K : IHashable
{
Method1(param1.GetEnumerator());
Method1((IEnumerator<(K key, V value)>)param1.GetEnumerator());
//*Method3_BadCall
return Method3<Dictionary<K, V>.Enumerator, (K key, V value)>(param1.GetEnumerator());
/*@*/
/*Method3_GoodCall
return Method2<Dictionary<K, V>.Enumerator, (K key, V value)>(param1.GetEnumerator());
*/
}
static void Main()
{
Dicto dicto = scope .();
Method3(dicto);
}
}
}

View file

@ -99,6 +99,9 @@ namespace IDE.Compiler
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetTypeDefInfo(void* bfCompiler, char8* typeDefName);
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetTypeInfo(void* bfCompiler, char8* typeName);
[CallingConvention(.Stdcall), CLink]
static extern void BfCompiler_SetOptions(void* bfCompiler,
void* hotProject, int32 hotIdx, char8* targetTriple, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
@ -682,6 +685,11 @@ namespace IDE.Compiler
outStr.Append(BfCompiler_GetTypeDefInfo(mNativeBfCompiler, typeDefName));
}
public void GetTypeInfo(String typeDefName, String outStr)
{
outStr.Append(BfCompiler_GetTypeInfo(mNativeBfCompiler, typeDefName));
}
public void ClearBuildCache()
{
BfCompiler_ClearBuildCache(mNativeBfCompiler);

View file

@ -4417,7 +4417,8 @@ namespace IDE
if (!mInitialized)
return;
#if !CLI
mLastActivePanel = panel;
if (setFocus)
mLastActivePanel = panel;
RecordHistoryLocation();
ShowTab(panel, label, false, setFocus);
if (setFocus)
@ -4580,7 +4581,7 @@ namespace IDE
[IDECommand]
public void ShowOutput()
{
ShowPanel(mOutputPanel, "Output");
ShowPanel(mOutputPanel, "Output", false);
}
[IDECommand]

View file

@ -1513,6 +1513,17 @@ namespace IDE
}
}
[IDECommand]
public void AssertTypeInfo(int compilerId, String typeName, String wantTypeInfo)
{
String typeInfo = scope String();
var compiler = (compilerId == 0) ? gApp.mBfResolveCompiler : gApp.mBfBuildCompiler;
compiler.GetTypeInfo(typeName, typeInfo);
if (typeInfo != wantTypeInfo)
mScriptManager.Fail("Assert failed: {0} == {1}", typeInfo, wantTypeInfo);
}
[IDECommand]
public void AddWatch(String evalStr)
{