Fixed issues where userdata types could sometimes cause crashes

This commit is contained in:
Deukhoofd 2019-02-16 15:24:30 +01:00
parent 8829df0ba3
commit 80afeacda6
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 6 additions and 5 deletions

View File

@ -16,7 +16,7 @@ namespace Upsilon.Binder
public bool IsCoroutine { get; }
public BoundFunctionExpression(ImmutableArray<BoundVariableSymbol> parameters, BoundBlockStatement block,
TextSpan span, BoundScope scope, Type returnType, bool isCoroutine) : base(span)
TextSpan span, BoundScope scope, TypeContainer returnType, bool isCoroutine) : base(span)
{
Parameters = parameters;
Block = block;
@ -36,7 +36,7 @@ namespace Upsilon.Binder
yield return Block;
}
public override TypeContainer ValueType => BaseTypes.Type.Function;
public override TypeContainer ValueType => Type.Function;
internal override ScriptType Evaluate(EvaluationScope scope, Diagnostics diagnostics, ref EvaluationState state)
{
var option = new ScriptRuntimeFunction.ScriptRuntimeFunctionOption(Parameters, Block, scope);
@ -47,6 +47,6 @@ namespace Upsilon.Binder
}
public BoundScope Scope { get; set; }
public Type ReturnType { get; }
public TypeContainer ReturnType { get; }
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Upsilon.BaseTypes;
using Upsilon.Binder.VariableSymbols;
using Type = Upsilon.BaseTypes.Type;
@ -10,7 +11,7 @@ namespace Upsilon.Binder
public readonly BoundScope ParentScope;
public BoundScope ReadOnlyScope { get; private set; }
public readonly Dictionary<string, VariableSymbol> Variables;
public Type ReturnType { get; set; } = Type.Nil;
public TypeContainer ReturnType { get; set; } = Type.Nil;
public BoundScope(BoundScope parentScope)
{

View File

@ -7,7 +7,7 @@ namespace Upsilon.Binder.VariableSymbols
{
public class ScriptFunctionVariableSymbol : FunctionVariableSymbol
{
public ScriptFunctionVariableSymbol(string name, bool local, ImmutableArray<VariableSymbol> parameters, Type resultType,
public ScriptFunctionVariableSymbol(string name, bool local, ImmutableArray<VariableSymbol> parameters, TypeContainer resultType,
bool isCoroutine)
: base(name, local, isCoroutine)
{