Skip to content

Commit 03902a3

Browse files
Merge #958: Clarify string coercion errors
2 parents 7d03180 + 46d6d61 commit 03902a3

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/Nix/Convert.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ instance ( Convertible e t f m
204204
(M.lookup "outPath" s)
205205
_ -> stub
206206

207-
fromValue = fromMayToValue $ TString mempty
207+
fromValue = fromMayToValue $ TString HasContext
208208

209209
instance Convertible e t f m
210210
=> FromValue ByteString m (NValue' t f m (NValue t f m)) where

src/Nix/Eval.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,9 @@ assembleString
467467
. (MonadEval v m, FromValue NixString m v)
468468
=> NString (m v)
469469
-> m (Maybe NixString)
470-
assembleString =
471-
fromParts .
472-
\case
473-
Indented _ parts -> parts
474-
DoubleQuoted parts -> parts
470+
assembleString = fromParts . stringParts
475471
where
476472
fromParts xs = (mconcat <$>) . sequence <$> traverse go xs
477-
478473
go =
479474
runAntiquoted
480475
"\n"

src/Nix/Expr/Types.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,10 @@ paramName :: Params r -> Maybe VarName
654654
paramName (Param n ) = pure n
655655
paramName (ParamSet _ _ n) = n
656656

657+
stringParts :: NString r -> [Antiquoted Text r]
658+
stringParts (DoubleQuoted parts) = parts
659+
stringParts (Indented _ parts) = parts
660+
657661
stripPositionInfo :: NExpr -> NExpr
658662
stripPositionInfo = transport phi
659663
where

src/Nix/Value.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ describeValue =
753753
TFloat -> "a float"
754754
TBool -> "a boolean"
755755
TNull -> "a null"
756-
TString NoContext -> "a string"
757-
TString HasContext -> "a string with context"
756+
TString NoContext -> "a string with no context"
757+
TString HasContext -> "a string"
758758
TList -> "a list"
759759
TSet -> "an attr set"
760760
TClosure -> "a function"

0 commit comments

Comments
 (0)