diff --git a/CHANGELOG.md b/CHANGELOG.md index 4412a793..511b5ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ [Read translated version (en)](./translations/en/CHANGELOG.md) +- インタプリタがreturn文を文字列化できるように + # 0.13.2 - `Date:year`,`Date:month`,`Date:day`,`Date:hour`,`Date:minute`,`Date:second`に時間数値の引数を渡して時刻指定可能に - array.sortとString用比較関数Str:lt, Str:gtの追加 diff --git a/src/interpreter/util.ts b/src/interpreter/util.ts index d7df51b0..c6b5d45c 100644 --- a/src/interpreter/util.ts +++ b/src/interpreter/util.ts @@ -100,6 +100,7 @@ export function valToString(val: Value, simple = false): string { if (val.type === 'str') return `"${val.value}"`; if (val.type === 'arr') return `[${val.value.map(item => valToString(item, true)).join(', ')}]`; if (val.type === 'null') return '(null)'; + if (val.type === 'return') return valToString(val.value, true); } const label = val.type === 'num' ? val.value : @@ -108,6 +109,7 @@ export function valToString(val: Value, simple = false): string { val.type === 'fn' ? '...' : val.type === 'obj' ? '...' : val.type === 'null' ? '' : + val.type === 'return' ? valToString(val.value) : null; return `${val.type}<${label}>`; }