Skip to content

Commit

Permalink
[ fix ] Data and Type Constructor tags for :di (#3395)
Browse files Browse the repository at this point in the history
* [ fix ] Data and Type Constructor tags for :di

* [ doc ] update changelog

* [ test ] add a test case

* [ test ] fix test output in basic039
  • Loading branch information
stefan-hoeck authored Oct 5, 2024
1 parent 536c7bf commit f840d1b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This CHANGELOG describes the history of already-released versions. Please see [C
and `Force`.
* Adds `--no-cse` command-line option to disable common subexpression elimination
for code generation debugging.
* Fixes a confusion between data and type constructors in the `:di` command.

### Backend changes

Expand Down
2 changes: 1 addition & 1 deletion src/Core/CompileExpr/Pretty.idr
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ prettyCDef (MkFun args exp) = reAnnotate Syntax $
keyword "\\" <++> concatWith (\ x, y => x <+> keyword "," <++> y) (map prettyName args)
<++> fatArrow <++> prettyCExp exp
prettyCDef (MkCon mtag arity nt)
= vcat $ header (maybe "Data" (const "Type") mtag <++> "Constructor") :: map (indent 2)
= vcat $ header (maybe "Type" (const "Data") mtag <++> "Constructor") :: map (indent 2)
( maybe [] (\ tag => ["tag:" <++> byShow tag]) mtag ++
[ "arity:" <++> byShow arity ] ++
maybe [] (\ n => ["newtype by:" <++> byShow n]) nt)
Expand Down
4 changes: 2 additions & 2 deletions tests/idris2/basic/basic039/expected
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Data constructor:
tag: 0
arity: 1
newtype by: (False, 0)
Compiled: Type Constructor:
Compiled: Data Constructor:
tag: 0
arity: 1
newtype by: 0
Expand All @@ -13,7 +13,7 @@ Main> Main.MkBar
Data constructor:
tag: 0
arity: 1
Compiled: Type Constructor:
Compiled: Data Constructor:
tag: 0
arity: 1
Flags: contype [record]
Expand Down
18 changes: 18 additions & 0 deletions tests/idris2/repl/repl007/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Main> Prelude.Basics.Bool
Type constructor:
tag: 100
arity: 0
parameter positions: []
constructors: Prelude.Basics.False, Prelude.Basics.True
Compiled: Type Constructor:
arity: 0
Main> Prelude.Basics.True
Data constructor:
tag: 1
arity: 0
Compiled: Data Constructor:
tag: 1
arity: 0
Flags: contype [enum 2]
Main>
Bye for now!
2 changes: 2 additions & 0 deletions tests/idris2/repl/repl007/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:di Bool
:di True
3 changes: 3 additions & 0 deletions tests/idris2/repl/repl007/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
. ../../../testutils.sh

idris2 < input

0 comments on commit f840d1b

Please sign in to comment.