# Tests that encoding built-in functions called with non-concrete arguments
# correctly return an "incomplete" error rather than panicking. Issue: calling
# csv.Decode or hex.EncodedLen with abstract (non-concrete) values caused a
# nil pointer dereference panic instead of a proper incomplete error.
# https://cuelang.org/issue/178
#name: Issue #178
#evalFull
-- in.cue --
import "encoding/csv"

import "encoding/hex"

foo:  csv.Decode(data) @test(err, code=incomplete)
data: bytes            @test(kind=bytes)

len: int                 @test(kind=int)
bar: hex.EncodedLen(len) @test(err, code=incomplete)
-- out/errors.txt --
[incomplete] foo: error in call to encoding/csv.Decode: non-concrete value bytes:
    ./in.cue:5:7
    ./in.cue:6:7
[incomplete] bar: error in call to encoding/hex.EncodedLen: non-concrete value int:
    ./in.cue:9:6
    ./in.cue:8:6
-- out/eval/stats --
Leaks:  0
Freed:  5
Reused: 0
Allocs: 5
Retain: 0

Unifications: 5
Conjuncts:    5
Disjuncts:    0
