Bump C++ version, implement std.trace, fix parsing of -$, update std (#224)

This commit is contained in:
Dave Cunningham 2018-05-23 22:24:12 -04:00 committed by GitHub
parent 643210d274
commit d9b833b8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 189938 additions and 21584 deletions

209886
ast/stdast.go

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"math" "math"
"os"
"sort" "sort"
"strings" "strings"
@ -243,6 +244,22 @@ func builtinToString(e *evaluator, xp potentialValue) (value, error) {
return makeValueString(buf.String()), nil return makeValueString(buf.String()), nil
} }
func builtinTrace(e *evaluator, xp potentialValue, yp potentialValue) (value, error) {
x, err := e.evaluateString(xp)
if err != nil {
return nil, err
}
y, err := e.evaluate(yp)
if err != nil {
return nil, err
}
filename := e.trace.loc.FileName
line := e.trace.loc.Begin.Line
fmt.Fprintf(
os.Stderr, "TRACE: %s:%d %s\n", filename, line, x.getString())
return y, nil
}
func builtinMakeArray(e *evaluator, szp potentialValue, funcp potentialValue) (value, error) { func builtinMakeArray(e *evaluator, szp potentialValue, funcp potentialValue) (value, error) {
sz, err := e.evaluateInt(szp) sz, err := e.evaluateInt(szp)
if err != nil { if err != nil {
@ -730,9 +747,8 @@ type unaryBuiltin struct {
} }
func getBuiltinEvaluator(e *evaluator, name ast.Identifier) *evaluator { func getBuiltinEvaluator(e *evaluator, name ast.Identifier) *evaluator {
loc := ast.MakeLocationRangeMessage("<builtin>")
context := "builtin function <" + string(name) + ">" context := "builtin function <" + string(name) + ">"
trace := TraceElement{loc: &loc, context: &context} trace := TraceElement{loc: e.trace.loc, context: &context}
return &evaluator{i: e.i, trace: &trace} return &evaluator{i: e.i, trace: &trace}
} }
@ -870,6 +886,7 @@ var funcBuiltins = buildBuiltinMap([]builtin{
&unaryBuiltin{name: "extVar", function: builtinExtVar, parameters: ast.Identifiers{"x"}}, &unaryBuiltin{name: "extVar", function: builtinExtVar, parameters: ast.Identifiers{"x"}},
&unaryBuiltin{name: "length", function: builtinLength, parameters: ast.Identifiers{"x"}}, &unaryBuiltin{name: "length", function: builtinLength, parameters: ast.Identifiers{"x"}},
&unaryBuiltin{name: "toString", function: builtinToString, parameters: ast.Identifiers{"a"}}, &unaryBuiltin{name: "toString", function: builtinToString, parameters: ast.Identifiers{"a"}},
&binaryBuiltin{name: "trace", function: builtinTrace, parameters: ast.Identifiers{"str", "rest"}},
&binaryBuiltin{name: "makeArray", function: builtinMakeArray, parameters: ast.Identifiers{"sz", "func"}}, &binaryBuiltin{name: "makeArray", function: builtinMakeArray, parameters: ast.Identifiers{"sz", "func"}},
&binaryBuiltin{name: "flatMap", function: builtinFlatMap, parameters: ast.Identifiers{"func", "arr"}}, &binaryBuiltin{name: "flatMap", function: builtinFlatMap, parameters: ast.Identifiers{"func", "arr"}},
&binaryBuiltin{name: "join", function: builtinJoin, parameters: ast.Identifiers{"sep", "arr"}}, &binaryBuiltin{name: "join", function: builtinJoin, parameters: ast.Identifiers{"sep", "arr"}},

@ -1 +1 @@
Subproject commit 9829acf280a64b58ad0b14c9f5c28fe8564ed13e Subproject commit aec4e0868bf3b10136ff480630aa5fe01554330f

View File

@ -669,7 +669,7 @@ func (l *lexer) lexSymbol() error {
// no need to treat this substring as general UTF-8. // no need to treat this substring as general UTF-8.
for r = rune(l.input[l.pos.byteNo-1]); l.pos.byteNo > l.tokenStart+1; l.pos.byteNo-- { for r = rune(l.input[l.pos.byteNo-1]); l.pos.byteNo > l.tokenStart+1; l.pos.byteNo-- {
switch r { switch r {
case '+', '-', '~', '!': case '+', '-', '~', '!', '$':
continue continue
} }
break break

View File

@ -23,6 +23,7 @@ limitations under the License.
{ {
local std = self, local std = self,
local id = function(x) x,
isString(v):: std.type(v) == 'string', isString(v):: std.type(v) == 'string',
isNumber(v):: std.type(v) == 'number', isNumber(v):: std.type(v) == 'number',
@ -61,18 +62,39 @@ limitations under the License.
stringChars(str):: stringChars(str)::
std.makeArray(std.length(str), function(i) str[i]), std.makeArray(std.length(str), function(i) str[i]),
local parse_nat(str, base) =
assert base > 0 && base <= 16 : 'integer base %d invalid' % base;
// These codepoints are in ascending order:
local zero_code = std.codepoint('0');
local upper_a_code = std.codepoint('A');
local lower_a_code = std.codepoint('a');
local addDigit(aggregate, char) =
local code = std.codepoint(char);
local digit = if code > lower_a_code then
code - lower_a_code + 10
else if code > upper_a_code then
code - upper_a_code + 10
else
code - zero_code;
assert digit >= 0 && digit < base : '%s is not a base %d integer' % [str, base];
base * aggregate + digit;
std.foldl(addDigit, std.stringChars(str), 0),
parseInt(str):: parseInt(str)::
local addDigit(aggregate, digit) =
if digit < 0 || digit > 9 then
error ('parseInt got string which does not match regex [0-9]+')
else
10 * aggregate + digit;
local toDigits(str) =
[std.codepoint(char) - std.codepoint('0') for char in std.stringChars(str)];
if str[0] == '-' then if str[0] == '-' then
-std.foldl(addDigit, toDigits(str[1:]), 0) -parse_nat(str[1:], 10)
else else
std.foldl(addDigit, toDigits(str), 0), parse_nat(str, 10),
parseOctal(str)::
assert std.isString(str): 'Expected string, got ' + std.type(str);
assert std.length(str) > 0: 'Not an octal number: ""';
parse_nat(str, 8),
parseHex(str)::
assert std.isString(str): 'Expected string, got ' + std.type(str);
assert std.length(str) > 0: 'Not hexadecimal: ""';
parse_nat(str, 16),
split(str, c):: split(str, c)::
if std.type(str) != 'string' then if std.type(str) != 'string' then
@ -1066,60 +1088,61 @@ limitations under the License.
std.join('', std.map(function(b) std.char(b), bytes)), std.join('', std.map(function(b) std.char(b), bytes)),
// Quicksort // Quicksort
sort(arr):: sort(arr, keyF=id)::
local l = std.length(arr); local l = std.length(arr);
if std.length(arr) == 0 then if std.length(arr) == 0 then
[] []
else else
local pivot = arr[0]; local pivot = keyF(arr[0]);
local rest = std.makeArray(l - 1, function(i) arr[i + 1]); local rest = std.makeArray(l - 1, function(i) arr[i + 1]);
local left = std.filter(function(x) x <= pivot, rest); local left = std.filter(function(x) keyF(x) < pivot, rest);
local right = std.filter(function(x) x > pivot, rest); local right = std.filter(function(x) keyF(x) >= pivot, rest);
std.sort(left) + [pivot] + std.sort(right), std.sort(left, keyF) + [arr[0]] + std.sort(right, keyF),
uniq(arr):: uniq(arr, keyF=id)::
local f(a, b) = local f(a, b) =
if std.length(a) == 0 then if std.length(a) == 0 then
[b] [b]
else if a[std.length(a) - 1] == b then else if keyF(a[std.length(a) - 1]) == keyF(b) then
a a
else else
a + [b]; a + [b];
std.foldl(f, arr, []), std.foldl(f, arr, []),
set(arr):: set(arr, keyF=id)::
std.uniq(std.sort(arr)), std.uniq(std.sort(arr, keyF), keyF),
setMember(x, arr):: setMember(x, arr, keyF=id)::
// TODO(dcunnin): Binary chop for O(log n) complexity // TODO(dcunnin): Binary chop for O(log n) complexity
std.length(std.setInter([x], arr)) > 0, std.length(std.setInter([x], arr, keyF)) > 0,
setUnion(a, b):: setUnion(a, b, keyF=id)::
std.set(a + b), // NOTE: order matters, values in `a` win due to sort being stable
std.set(a + b, keyF),
setInter(a, b):: setInter(a, b, keyF=id)::
local aux(a, b, i, j, acc) = local aux(a, b, i, j, acc) =
if i >= std.length(a) || j >= std.length(b) then if i >= std.length(a) || j >= std.length(b) then
acc acc
else else
if a[i] == b[j] then if keyF(a[i]) == keyF(b[j]) then
aux(a, b, i + 1, j + 1, acc + [a[i]]) tailstrict aux(a, b, i + 1, j + 1, acc + [a[i]]) tailstrict
else if a[i] < b[j] then else if keyF(a[i]) < keyF(b[j]) then
aux(a, b, i + 1, j, acc) tailstrict aux(a, b, i + 1, j, acc) tailstrict
else else
aux(a, b, i, j + 1, acc) tailstrict; aux(a, b, i, j + 1, acc) tailstrict;
aux(a, b, 0, 0, []) tailstrict, aux(a, b, 0, 0, []) tailstrict,
setDiff(a, b):: setDiff(a, b, keyF=id)::
local aux(a, b, i, j, acc) = local aux(a, b, i, j, acc) =
if i >= std.length(a) then if i >= std.length(a) then
acc acc
else if j >= std.length(b) then else if j >= std.length(b) then
aux(a, b, i + 1, j, acc + [a[i]]) tailstrict aux(a, b, i + 1, j, acc + [a[i]]) tailstrict
else else
if a[i] == b[j] then if keyF(a[i]) == keyF(b[j]) then
aux(a, b, i + 1, j + 1, acc) tailstrict aux(a, b, i + 1, j + 1, acc) tailstrict
else if a[i] < b[j] then else if keyF(a[i]) < keyF(b[j]) then
aux(a, b, i + 1, j, acc + [a[i]]) tailstrict aux(a, b, i + 1, j, acc + [a[i]]) tailstrict
else else
aux(a, b, i, j + 1, acc) tailstrict; aux(a, b, i, j + 1, acc) tailstrict;

View File

@ -5,7 +5,7 @@ RUNTIME ERROR: x
[x for x in [1] if error "x"] [x for x in [1] if error "x"]
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <flatMap> builtin function <flatMap>
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -3,7 +3,7 @@ RUNTIME ERROR: Unexpected type number, expected boolean
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <flatMap> builtin function <flatMap>
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,6 @@
RUNTIME ERROR: Assertion failed. {"x": 1} != {"x": 2} RUNTIME ERROR: Assertion failed. {"x": 1} != {"x": 2}
------------------------------------------------- -------------------------------------------------
<std>:758:7-50 function <anonymous> <std>:780:7-50 function <anonymous>
error 'Assertion failed. ' + a + ' != ' + b, error 'Assertion failed. ' + a + ' != ' + b,

View File

@ -2,7 +2,7 @@ RUNTIME ERROR: Assertion failed.
!= !=
------------------------------------------------- -------------------------------------------------
<std>:758:7-50 function <anonymous> <std>:780:7-50 function <anonymous>
error 'Assertion failed. ' + a + ' != ' + b, error 'Assertion failed. ' + a + ' != ' + b,

View File

@ -1,6 +1,6 @@
RUNTIME ERROR: Assertion failed.  != RUNTIME ERROR: Assertion failed.  !=
------------------------------------------------- -------------------------------------------------
<std>:758:7-50 function <anonymous> <std>:780:7-50 function <anonymous>
error 'Assertion failed. ' + a + ' != ' + b, error 'Assertion failed. ' + a + ' != ' + b,

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Codepoints must be >= 0, got -1 RUNTIME ERROR: Codepoints must be >= 0, got -1
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <char> testdata/builtinChar3:1:1-13 builtin function <char>
std.char(-1)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Invalid unicode codepoint, got 1.114112e+06 RUNTIME ERROR: Invalid unicode codepoint, got 1.114112e+06
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <char> testdata/builtinChar5:2:1-18 builtin function <char>
std.char(1114112)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <char> testdata/builtinChar7:1:1-16 builtin function <char>
std.char("xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected object RUNTIME ERROR: Unexpected type number, expected object
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <objectFieldsEx> testdata/builtinObjectFieldsEx_bad:1:1-29 builtin function <objectFieldsEx>
std.objectFieldsEx(42, true)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected boolean RUNTIME ERROR: Unexpected type string, expected boolean
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <objectFieldsEx> testdata/builtinObjectFieldsEx_bad2:1:1-30 builtin function <objectFieldsEx>
std.objectFieldsEx({}, "xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected boolean RUNTIME ERROR: Unexpected type string, expected boolean
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <objectHasEx> testdata/builtinObjectHasExBadBoolean:1:1-34 builtin function <objectHasEx>
std.objectHasEx({}, "xxx", "xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected string RUNTIME ERROR: Unexpected type number, expected string
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <objectHasEx> testdata/builtinObjectHasExBadField:1:1-31 builtin function <objectHasEx>
std.objectHasEx({}, 42, false)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected object RUNTIME ERROR: Unexpected type number, expected object
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <objectHasEx> testdata/builtinObjectHasExBadObject:1:1-32 builtin function <objectHasEx>
std.objectHasEx(42, "x", false)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Overflow RUNTIME ERROR: Overflow
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <exp> testdata/builtin_exp3:1:1-14 builtin function <exp>
std.exp(1000)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Overflow RUNTIME ERROR: Overflow
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <exp> testdata/builtin_exp5:1:1-31 builtin function <exp>
std.exp(100000000000000000000)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Overflow RUNTIME ERROR: Overflow
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <log> testdata/builtin_log5:1:1-11 builtin function <log>
std.log(0)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Not a number RUNTIME ERROR: Not a number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <log> testdata/builtin_log7:1:1-12 builtin function <log>
std.log(-1)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Not a number RUNTIME ERROR: Not a number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <log> testdata/builtin_log8:1:1-24 builtin function <log>
std.log(-1000000000000)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <sqrt> testdata/builtin_sqrt2:1:1-19 builtin function <sqrt>
std.sqrt("cookie")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,9 @@ RUNTIME ERROR: xxx
error 'xxx' error 'xxx'
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <extVar> testdata/extvar_error:1:1-23 builtin function <extVar>
std.extVar("errorVar")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected string RUNTIME ERROR: Unexpected type number, expected string
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <extVar> testdata/extvar_not_a_string:1:1-15 builtin function <extVar>
std.extVar(42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Undefined external variable: UNKNOWN RUNTIME ERROR: Undefined external variable: UNKNOWN
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <extVar> testdata/extvar_unknown:1:1-22 builtin function <extVar>
std.extVar("UNKNOWN")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unrecognized native function name: blah RUNTIME ERROR: Unrecognized native function name: blah
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <native> testdata/native_nonexistent:1:1-19 builtin function <native>
std.native("blah")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,6 @@
RUNTIME ERROR: Duplicate field name: "x" RUNTIME ERROR: Duplicate field name: "x"
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <$objectFlatMerge> builtin function <$objectFlatMerge>
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,7 @@ RUNTIME ERROR: xxx
{ [error "xxx"]: 42 for x in [1] } { [error "xxx"]: 42 for x in [1] }
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <$objectFlatMerge> builtin function <$objectFlatMerge>
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,7 @@ RUNTIME ERROR: Field name must be string, got number
{ [x]: x for x in [1, 2, 3] } { [x]: x for x in [1, 2, 3] }
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <$objectFlatMerge> builtin function <$objectFlatMerge>
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,23 +5,27 @@ RUNTIME ERROR: Attempt to use super when there is no super class.
{ x: 5, assert super.x == 5 } { x: 5, assert super.x == 5 }
------------------------------------------------- -------------------------------------------------
<std>:1165:25-26 thunk from <thunk <ta> from <function <anonymous>>> <std>:1188:25-26 thunk from <thunk <ta> from <function <anonymous>>>
local ta = std.type(a); local ta = std.type(a);
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <type> <std>:1188:16-27 builtin function <type>
local ta = std.type(a);
------------------------------------------------- -------------------------------------------------
<std>:1167:29-31 thunk from <function <anonymous>> <std>:1190:29-31 thunk from <function <anonymous>>
if !std.primitiveEquals(ta, tb) then if !std.primitiveEquals(ta, tb) then
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <primitiveEquals> <std>:1190:9-36 builtin function <primitiveEquals>
if !std.primitiveEquals(ta, tb) then
------------------------------------------------- -------------------------------------------------
<std>:1167:8-36 function <anonymous> <std>:1190:8-36 function <anonymous>
if !std.primitiveEquals(ta, tb) then if !std.primitiveEquals(ta, tb) then

View File

@ -1,6 +1,6 @@
RUNTIME ERROR: Operator % cannot be used on types number and string. RUNTIME ERROR: Operator % cannot be used on types number and string.
------------------------------------------------- -------------------------------------------------
<std>:205:7-94 function <anonymous> <std>:227:7-94 function <anonymous>
error 'Operator % cannot be used on types ' + std.type(a) + ' and ' + std.type(b) + '.', error 'Operator % cannot be used on types ' + std.type(a) + ' and ' + std.type(b) + '.',

View File

@ -1,21 +1,21 @@
RUNTIME ERROR: Too many values to format: 1, expected 0 RUNTIME ERROR: Too many values to format: 1, expected 0
------------------------------------------------- -------------------------------------------------
<std>:628:11-86 function <format_codes_arr> <std>:650:11-86 function <format_codes_arr>
error ('Too many values to format: ' + std.length(arr) + ', expected ' + j) error ('Too many values to format: ' + std.length(arr) + ', expected ' + j)
------------------------------------------------- -------------------------------------------------
<std>:634:11-59 function <format_codes_arr> <std>:656:11-59 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict
------------------------------------------------- -------------------------------------------------
<std>:725:7-48 function <anonymous> <std>:747:7-48 function <anonymous>
format_codes_arr(codes, [vals], 0, 0, ''), format_codes_arr(codes, [vals], 0, 0, ''),
------------------------------------------------- -------------------------------------------------
<std>:203:7-23 function <anonymous> <std>:225:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,6 +1,6 @@
RUNTIME ERROR: Operator % cannot be used on types function and number. RUNTIME ERROR: Operator % cannot be used on types function and number.
------------------------------------------------- -------------------------------------------------
<std>:205:7-94 function <anonymous> <std>:227:7-94 function <anonymous>
error 'Operator % cannot be used on types ' + std.type(a) + ' and ' + std.type(b) + '.', error 'Operator % cannot be used on types ' + std.type(a) + ' and ' + std.type(b) + '.',

View File

@ -1,21 +1,21 @@
RUNTIME ERROR: Too many values to format: 2, expected 1 RUNTIME ERROR: Too many values to format: 2, expected 1
------------------------------------------------- -------------------------------------------------
<std>:628:11-86 function <format_codes_arr> <std>:650:11-86 function <format_codes_arr>
error ('Too many values to format: ' + std.length(arr) + ', expected ' + j) error ('Too many values to format: ' + std.length(arr) + ', expected ' + j)
------------------------------------------------- -------------------------------------------------
<std>:634:11-59 function <format_codes_arr> <std>:656:11-59 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict
------------------------------------------------- -------------------------------------------------
<std>:721:7-46 function <anonymous> <std>:743:7-46 function <anonymous>
format_codes_arr(codes, vals, 0, 0, '') format_codes_arr(codes, vals, 0, 0, '')
------------------------------------------------- -------------------------------------------------
<std>:203:7-23 function <anonymous> <std>:225:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,36 +1,38 @@
RUNTIME ERROR: Not enough values to format, got 1 RUNTIME ERROR: Not enough values to format, got 1
------------------------------------------------- -------------------------------------------------
<std>:661:15-74 thunk <val> from <function <format_codes_arr>> <std>:683:15-74 thunk <val> from <function <format_codes_arr>>
error 'Not enough values to format, got ' + std.length(arr); error 'Not enough values to format, got ' + std.length(arr);
------------------------------------------------- -------------------------------------------------
<std>:666:27-30 thunk from <thunk <s> from <function <format_codes_arr>>> <std>:688:27-30 thunk from <thunk <s> from <function <format_codes_arr>>>
format_code(val, code, tmp.fw, tmp2.prec, j2); format_code(val, code, tmp.fw, tmp2.prec, j2);
------------------------------------------------- -------------------------------------------------
<std>:536:22-25 thunk from <function <format_code>> <std>:558:22-25 thunk from <function <format_code>>
std.toString(val) std.toString(val)
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <toString> <std>:558:9-26 builtin function <toString>
std.toString(val)
------------------------------------------------- -------------------------------------------------
... (skipped 14 frames) ... (skipped 14 frames)
------------------------------------------------- -------------------------------------------------
<std>:677:11-64 function <format_codes_arr> <std>:699:11-64 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict; format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict;
------------------------------------------------- -------------------------------------------------
<std>:721:7-46 function <anonymous> <std>:743:7-46 function <anonymous>
format_codes_arr(codes, vals, 0, 0, '') format_codes_arr(codes, vals, 0, 0, '')
------------------------------------------------- -------------------------------------------------
<std>:203:7-23 function <anonymous> <std>:225:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,36 +1,38 @@
RUNTIME ERROR: Not enough values to format, got 1 RUNTIME ERROR: Not enough values to format, got 1
------------------------------------------------- -------------------------------------------------
<std>:661:15-74 thunk <val> from <function <format_codes_arr>> <std>:683:15-74 thunk <val> from <function <format_codes_arr>>
error 'Not enough values to format, got ' + std.length(arr); error 'Not enough values to format, got ' + std.length(arr);
------------------------------------------------- -------------------------------------------------
<std>:666:27-30 thunk from <thunk <s> from <function <format_codes_arr>>> <std>:688:27-30 thunk from <thunk <s> from <function <format_codes_arr>>>
format_code(val, code, tmp.fw, tmp2.prec, j2); format_code(val, code, tmp.fw, tmp2.prec, j2);
------------------------------------------------- -------------------------------------------------
<std>:536:22-25 thunk from <function <format_code>> <std>:558:22-25 thunk from <function <format_code>>
std.toString(val) std.toString(val)
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <toString> <std>:558:9-26 builtin function <toString>
std.toString(val)
------------------------------------------------- -------------------------------------------------
... (skipped 14 frames) ... (skipped 14 frames)
------------------------------------------------- -------------------------------------------------
<std>:677:11-64 function <format_codes_arr> <std>:699:11-64 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict; format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict;
------------------------------------------------- -------------------------------------------------
<std>:725:7-48 function <anonymous> <std>:747:7-48 function <anonymous>
format_codes_arr(codes, [vals], 0, 0, ''), format_codes_arr(codes, [vals], 0, 0, ''),
------------------------------------------------- -------------------------------------------------
<std>:203:7-23 function <anonymous> <std>:225:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,39 +1,39 @@
RUNTIME ERROR: Format required number at 0, got string RUNTIME ERROR: Format required number at 0, got string
------------------------------------------------- -------------------------------------------------
<std>:(539:11)-(540:47) function <format_code> <std>:(561:11)-(562:47) function <format_code>
error 'Format required number at ' error 'Format required number at '
+ i + ', got ' + std.type(val) + i + ', got ' + std.type(val)
------------------------------------------------- -------------------------------------------------
<std>:666:15-60 thunk <s> from <function <format_codes_arr>> <std>:688:15-60 thunk <s> from <function <format_codes_arr>>
format_code(val, code, tmp.fw, tmp2.prec, j2); format_code(val, code, tmp.fw, tmp2.prec, j2);
------------------------------------------------- -------------------------------------------------
<std>:671:24-25 thunk from <thunk <s_padded> from <function <format_codes_arr>>> <std>:693:24-25 thunk from <thunk <s_padded> from <function <format_codes_arr>>>
pad_left(s, tmp.fw, ' '); pad_left(s, tmp.fw, ' ');
------------------------------------------------- -------------------------------------------------
<std>:451:30-33 thunk from <thunk from <function <pad_left>>> <std>:473:30-33 thunk from <thunk from <function <pad_left>>>
padding(w - std.length(str), s) + str; padding(w - std.length(str), s) + str;
------------------------------------------------- -------------------------------------------------
... (skipped 11 frames) ... (skipped 11 frames)
------------------------------------------------- -------------------------------------------------
<std>:677:11-64 function <format_codes_arr> <std>:699:11-64 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict; format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict;
------------------------------------------------- -------------------------------------------------
<std>:721:7-46 function <anonymous> <std>:743:7-46 function <anonymous>
format_codes_arr(codes, vals, 0, 0, '') format_codes_arr(codes, vals, 0, 0, '')
------------------------------------------------- -------------------------------------------------
<std>:203:7-23 function <anonymous> <std>:225:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Division by zero. RUNTIME ERROR: Division by zero.
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <modulo> <std>:223:7-23 builtin function <modulo>
std.modulo(a, b)
------------------------------------------------- -------------------------------------------------

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Not a number RUNTIME ERROR: Not a number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <pow> testdata/pow4:1:1-17 builtin function <pow>
std.pow(-1, 0.2)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Overflow RUNTIME ERROR: Overflow
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <pow> testdata/pow7:2:1-23 builtin function <pow>
std.pow(1.1, 7447.082)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <pow> testdata/pow8:1:1-19 builtin function <pow>
std.pow("xxx", 42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <pow> testdata/pow9:1:1-19 builtin function <pow>
std.pow(42, "xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: codepoint takes a string of length 1, got length 2 RUNTIME ERROR: codepoint takes a string of length 1, got length 2
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <codepoint> testdata/std.codepoint3:1:1-20 builtin function <codepoint>
std.codepoint("aa")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: codepoint takes a string of length 1, got length 0 RUNTIME ERROR: codepoint takes a string of length 1, got length 0
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <codepoint> testdata/std.codepoint6:1:1-18 builtin function <codepoint>
std.codepoint("")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: codepoint takes a string of length 1, got length 2 RUNTIME ERROR: codepoint takes a string of length 1, got length 2
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <codepoint> testdata/std.codepoint7:2:1-21 builtin function <codepoint>
std.codepoint("ą")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected string RUNTIME ERROR: Unexpected type number, expected string
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <codepoint> testdata/std.codepoint8:1:1-18 builtin function <codepoint>
std.codepoint(42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,9 @@ RUNTIME ERROR: x
std.filter(error "x", []) std.filter(error "x", [])
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <filter> testdata/std.filter2:1:1-26 builtin function <filter>
std.filter(error "x", [])
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected function RUNTIME ERROR: Unexpected type number, expected function
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <filter> testdata/std.filter4:1:1-19 builtin function <filter>
std.filter(42, [])
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected array RUNTIME ERROR: Unexpected type number, expected array
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <filter> testdata/std.filter5:1:1-31 builtin function <filter>
std.filter(function(n) 42, 42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected array RUNTIME ERROR: Unexpected type string, expected array
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <filter> testdata/std.filter6:1:1-21 builtin function <filter>
std.filter(42, "42")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type function, expected array RUNTIME ERROR: Unexpected type function, expected array
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <filter> testdata/std.filter8:1:1-36 builtin function <filter>
std.filter([42], function(i) "xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type function, expected array RUNTIME ERROR: Unexpected type function, expected array
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <filter> testdata/std.filter_swapped_args:1:1-38 builtin function <filter>
std.filter([1,2,3], function(n) true)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,10 +5,14 @@ RUNTIME ERROR: a
local failWith(x) = error x; local failWith(x) = error x;
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <flatMap> testdata/std.flatmap5:2:10-48 builtin function <flatMap>
std.type(std.flatMap(failWith, ["a", "b", "c"]))
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <type> testdata/std.flatmap5:2:1-49 builtin function <type>
std.type(std.flatMap(failWith, ["a", "b", "c"]))
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type array, expected string RUNTIME ERROR: Unexpected type array, expected string
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <join> testdata/std.join7:1:1-27 builtin function <join>
std.join("aa", [[1], [2]])
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected array RUNTIME ERROR: Unexpected type string, expected array
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <join> testdata/std.join8:1:1-33 builtin function <join>
std.join([3, 4], [[1, 2], "56"])
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <makeArray> testdata/std.makeArray_bad:1:1-36 builtin function <makeArray>
std.makeArray("xxx", function(i) i)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected function RUNTIME ERROR: Unexpected type string, expected function
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <makeArray> testdata/std.makeArray_bad2:1:1-25 builtin function <makeArray>
std.makeArray(42, "xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Expected an integer, but got 2.5 RUNTIME ERROR: Expected an integer, but got 2.5
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <makeArray> testdata/std.makeArray_noninteger:1:1-34 builtin function <makeArray>
std.makeArray(2.5, function(i) i)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Expected an integer, but got 1e+100 RUNTIME ERROR: Expected an integer, but got 1e+100
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <makeArray> testdata/std.makeArray_noninteger_big:1:1-47 builtin function <makeArray>
std.makeArray(1e100, error "shouldn't happen")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type number, expected string RUNTIME ERROR: Unexpected type number, expected string
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <md5> testdata/std.md5_6:1:1-12 builtin function <md5>
std.md5(42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <modulo> testdata/std.modulo2:1:1-22 builtin function <modulo>
std.modulo("xxx", 42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Unexpected type string, expected number RUNTIME ERROR: Unexpected type string, expected number
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <modulo> testdata/std.modulo3:1:1-22 builtin function <modulo>
std.modulo("xxx", 42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,9 @@ RUNTIME ERROR: x
std.primitiveEquals(error "x", 42) std.primitiveEquals(error "x", 42)
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <primitiveEquals> testdata/std.primitiveEquals10:1:1-35 builtin function <primitiveEquals>
std.primitiveEquals(error "x", 42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: primitiveEquals operates on primitive types, got array RUNTIME ERROR: primitiveEquals operates on primitive types, got array
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <primitiveEquals> testdata/std.primitiveEquals13:1:1-28 builtin function <primitiveEquals>
std.primitiveEquals([], [])
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: primitiveEquals operates on primitive types, got object RUNTIME ERROR: primitiveEquals operates on primitive types, got object
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <primitiveEquals> testdata/std.primitiveEquals6:1:1-28 builtin function <primitiveEquals>
std.primitiveEquals({}, {})
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: Cannot test equality of functions RUNTIME ERROR: Cannot test equality of functions
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <primitiveEquals> testdata/std.primitiveEquals7:1:1-50 builtin function <primitiveEquals>
std.primitiveEquals(function() 42, function() 42)
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,9 @@ RUNTIME ERROR: x
std.primitiveEquals(42, error "x") std.primitiveEquals(42, error "x")
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <primitiveEquals> testdata/std.primitiveEquals9:1:1-35 builtin function <primitiveEquals>
std.primitiveEquals(42, error "x")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,9 @@ RUNTIME ERROR: x
std.toString(error "x") std.toString(error "x")
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <toString> testdata/std.toString5:1:1-24 builtin function <toString>
std.toString(error "x")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -1,6 +1,8 @@
RUNTIME ERROR: 'from' string must not be zero length. RUNTIME ERROR: 'from' string must not be zero length.
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <strReplace> testdata/strReplace3:1:1-35 builtin function <strReplace>
std.strReplace("test", "", "blah")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation

View File

@ -5,7 +5,9 @@ RUNTIME ERROR: xxx
std.type(error "xxx") std.type(error "xxx")
------------------------------------------------- -------------------------------------------------
<builtin> builtin function <type> testdata/type_error:1:1-22 builtin function <type>
std.type(error "xxx")
------------------------------------------------- -------------------------------------------------
During evaluation During evaluation