Skip to content

Commit 342ce75

Browse files
committed
[ ux ] Change a couple of error messages to be slightly more concrete
1 parent 5a51745 commit 342ce75

File tree

13 files changed

+24
-20
lines changed

13 files changed

+24
-20
lines changed

src/Deriving/DepTyCheck/Gen/Core/ConsDerive.idr

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ getTypeApps con = do
6363
-- we didn't found, failing, there are at least two reasons
6464
failAt (getFC lhs) $ if isNamespaced lhsName
6565
then "Data type `\{lhsName}` is unavailable at the site of derivation (forgotten import?)"
66-
else "Usupported applications to a non-concrete type `\{lhsName}`"
66+
else "Usupported applications to a non-concrete type `\{lhsName}` in \{show con.name}"
6767
IPrimVal _ (PrT t) => pure $ typeInfoForPrimType t
6868
IType _ => pure typeInfoForTypeOfTypes
69-
lhs@(IPi {}) => failAt (getFC lhs) "Fields with function types are not supported in constructors"
70-
lhs => failAt (getFC lhs) "Unsupported type of a constructor field: \{show lhs}"
69+
lhs@(IPi {}) => failAt (getFC lhs) "Fields with function types are not supported in constructors, like in \{show con.name}"
70+
lhs => failAt (getFC lhs) "Unsupported type of a constructor's \{show con.name} field: \{show lhs}"
7171
let Yes lengthCorrect = decEq ty.args.length args.length
7272
| No _ => failAt (getFC lhs) "INTERNAL ERROR: wrong count of unapp when analysing type application"
7373
_ <- ensureTyArgsNamed ty

src/Deriving/DepTyCheck/Gen/Core/ConsEntry.idr

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ canonicConsBody sig name con = do
4848
-- - something else (cannot manage yet)
4949
let deepConsApps = sig.givenParams.asVect <&> \idx => do
5050
let argExpr = conRetTypeArg idx
51-
mapFst (\err => ("Argument #\{show idx} is not supported yet, argument expression: \{show argExpr}, reason: \{err}", argExpr)) $
51+
mapFst (\err => ("Argument #\{show idx} of \{show con.name} with given type arguments [\{showGivens sig}] is not supported, " ++
52+
"argument expression: \{show argExpr}, reason: \{err}", argExpr)) $
5253
analyseDeepConsApp True conArgNames argExpr
5354
let allAppliedFreeNames = foldMap (either .| const empty .| SortedSet.fromList . map fst . fst) deepConsApps
5455
deepConsApps <- for deepConsApps $ \case

src/Deriving/DepTyCheck/Gen/Derive.idr

+9-6
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ public export %inline
3232
(.generatedParams) : (sig : GenSignature) -> SortedSet $ Fin sig.targetType.args.length
3333
sig.generatedParams = fromList (allFins sig.targetType.args.length) `difference` sig.givenParams
3434

35+
export
36+
showGivens : GenSignature -> String
37+
showGivens sig = joinBy ", " $ do
38+
let uName : Arg -> Maybe UserName
39+
uName $ MkArg {name=Just $ UN un, _} = Just un
40+
uName _ = Nothing
41+
sig.givenParams.asList <&> \idx => maybe (show idx) (\n => "\{show idx}(\{show n})") $ uName $ index' sig.targetType.args idx
42+
3543
export
3644
SingleLogPosition GenSignature where
37-
logPosition sig = do
38-
let uName : Arg -> Maybe UserName
39-
uName $ MkArg {name=Just $ UN un, _} = Just un
40-
uName _ = Nothing
41-
let givs = sig.givenParams.asList <&> \idx => maybe (show idx) (\n => "\{show idx}(\{show n})") $ uName $ index' sig.targetType.args idx
42-
"\{logPosition sig.targetType}[\{joinBy ", " givs}]"
45+
logPosition sig = "\{logPosition sig.targetType}[\{showGivens sig}]"
4346

4447
public export
4548
Eq GenSignature where

tests/derivation/core/non-cons given match 001-neg/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Argument #0 is not supported yet, argument expression: DerivedGen.boolToNat x, reason: name `DerivedGen.boolToNat` is not a constructor
3+
Error: While processing right hand side of checkedGen. Error during reflection: Argument #0 of DerivedGen.X2 with given type arguments [0] is not supported, argument expression: DerivedGen.boolToNat x, reason: name `DerivedGen.boolToNat` is not a constructor
44

55
DerivedGen:1
66
12 |

tests/derivation/core/norec part noext 003/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `ty`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `ty` in Prelude.Types.Just
44

55
DerivedGen:1
66
12 | XShow : Show X

tests/derivation/core/norec part noext 004/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a` in Builtin.MkPair
44

55
DerivedGen:1
66
13 | XShow = %runElab derive

tests/derivation/core/norec part noext 005/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a` in Builtin.MkPair
44

55
DerivedGen:1
66
13 | XShow = %runElab derive

tests/derivation/core/norec part w_ext 001/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `ty`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `ty` in Prelude.Types.Just
44

55
DerivedGen:1
66
13 | XShow = %runElab derive

tests/derivation/core/norec part w_ext 002/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a` in Builtin.MkPair
44

55
DerivedGen:1
66
13 | XShow = %runElab derive

tests/derivation/core/norec part w_ext 003/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a` in Builtin.MkPair
44

55
DerivedGen:1
66
13 | XShow = %runElab derive

tests/derivation/core/norec t-pi--.. noext 003/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a` in Builtin.Refl
44

55
DerivedGen:1
66
13 | Show (X b1 b2) where

tests/derivation/core/norec t-pi--.. noext 004/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1/2: Building RunDerivedGen (RunDerivedGen.idr)
22
2/2: Building DerivedGen (DerivedGen.idr)
3-
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a`
3+
Error: While processing right hand side of checkedGen. Error during reflection: Usupported applications to a non-concrete type `a` in Builtin.Refl
44

55
DerivedGen:1
66
15 | show (X0 b1 b2 _) = "X0 \{show b1} \{show b2} Refl"

tests/derivation/least-effort/run/regression/function-in-cons/expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
2/2: Building DerivedGen (DerivedGen.idr)
33
Error: While processing right hand side of checkedGen. Sorry, I can't find any elaboration which works. All errors:
44
Possible error:
5-
Error during reflection: Fields with function types are not supported in constructors
5+
Error during reflection: Fields with function types are not supported in constructors, like in DerivedGen.MkX
66

77
DerivedGen:1
88
4 |

0 commit comments

Comments
 (0)