1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-30 07:58:58 +01:00
Commit Graph

22 Commits

Author SHA1 Message Date
Oliver Steele
42035af9b1 Replace gometalinter -> golangci; fix lint errors 2021-06-16 18:42:31 +08:00
misko
dd12222409 1. fix 2019-12-20 19:51:52 +08:00
nsf
c32908a4f3 Returning proper error type causes less panics during expression eval.
When user-defined function is called, it does convert all the arguments using
MustConvert, which panics on error with an error. However 'func (e expression)
Evaluate(ctx Context)' from sub package "expressions" catches those panics and
converts some of them to errors. Raw errors returned from strconv functions
are "repanicked", but proper error types such as values.TypeError are not.
Hence we should use it here.
2018-05-31 23:49:25 +05:00
nsf
4354d48a04 Properly handle implicit conversion to integer types.
Go's reflect API is very picky about arguments to Call method. You can't just
pass in the "int" when function expects "int64", even on 64 bit machines. This
patch solves this problem by performing conversions properly. Truncation
problems however, as well as negative to uint issues are completely ignored.
Which is perhaps not ideal, but still better than returning "int" when "int32"
or "int64" is requested.

I did split the Kind switch cases and moved value -> int and value -> float
conversions to separate functions. An alternative to that would be using the
reflection API, which might be less performant. Not that it matters much, but
this solution is correct, even though looks a bit copy & pasty.

Oh and of course all "uint" types were completely missing in the function and
they are now added.
2018-05-31 23:18:57 +05:00
nsf
1a2066b87e Properly handle variadic functions.
This commit addresses two issues:

1. For variadic functions 'convertCallArguments' was allocating exactly
   'len(args)' arguments, which might be less than required, as a result
   zero/default filling loop would panic with out of bounds error.

2. Even if we correctly allocate a proper amount of arguments, zero/default
   filling loop doesn't handle special variadic function type case, when last
   argument has a slice type and reflect API expects plain values as arguments.
   But actually we don't need that, because it's okay to omit variadic values
   altogether, hence the total amount of allocated arguments is
   max(len(args), rt.NumIn()-1).
2018-05-30 19:44:29 +05:00
Oliver Steele
b6c65ffee6 map[unhashable] returns nil instead of panic 2017-08-23 16:03:46 -04:00
Oliver Steele
a50dc106d2 Convert tests 2017-08-23 15:56:27 -04:00
Oliver Steele
d27c839ae3 variable names 2017-08-23 15:56:18 -04:00
Oliver Steele
1a12f12f1d Convert MapSlice -> map 2017-08-21 15:06:35 -04:00
Oliver Steele
bb24f32cbd list filters operate on MapSlice 2017-08-21 10:30:54 -04:00
Oliver Steele
e1c7224d9c variable names 2017-08-21 09:50:29 -04:00
Oliver Steele
6b15fbf6c7 Tests; implement map[nil] 2017-08-09 08:45:48 -04:00
Oliver Steele
fd4d34c403 Nil pointers are equal, even if different types 2017-08-09 08:42:42 -04:00
Oliver Steele
62f44fa728 Rearrange value methods w/in file 2017-08-09 08:16:36 -04:00
Oliver Steele
9852226d22 Restore m['str'] where m map[interface{}]interface{} 2017-08-08 19:31:33 -04:00
Oliver Steele
e39a1fe0d4 Fix array[nil] 2017-08-08 17:15:29 -04:00
Oliver Steele
51d7166e88 Package docs 2017-08-08 16:42:32 -04:00
Oliver Steele
83652f59db Actually cache the drop resolution 2017-08-03 15:20:56 +02:00
Oliver Steele
7f501ce512 Race test, benchmarks, for drop resolution 2017-08-03 15:20:56 +02:00
James Littlejohn
b2f5f1f9ac Fix struct PropertyValue attempting to use an invalid pointer 2017-08-01 11:27:32 +10:00
Oliver Steele
9866cbf5d7 Race condition 2017-07-27 18:30:03 -04:00
Oliver Steele
6269836192 Move pkg evaluator -> values 2017-07-27 18:11:37 -04:00