添加结构体组合, interface x : a + b {}

This commit is contained in:
2026-02-08 22:20:12 +08:00
parent 537011df32
commit 1dadaca4cc
6 changed files with 121 additions and 9 deletions

View File

@@ -183,9 +183,9 @@ namespace Fig
// we've checked argument count before, so here
// must be a default value
// evaluate default value in definition context
// evaluate default value in definition context!
ObjectPtr defaultVal = check_unwrap(eval(field.defaultValue,
ctx)); // it can't be null here
defContext)); // it can't be null here
// type check
if (!isTypeMatch(expectedType, defaultVal, ctx))
@@ -345,13 +345,12 @@ namespace Fig
}
}
}
ContextPtr stDefCtx = structT.defContext;
// load struct method
for (auto &[id, fn] : stDefCtx->getFunctions())
for (auto &[id, fn] : defContext->getFunctions())
{
const FString &funcName = fn.name;
const auto &funcSlot = stDefCtx->get(funcName);
const auto &funcSlot = defContext->get(funcName);
instanceCtx->def(funcName,
ValueType::Function,