Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ fix ] Data and Type Constructor tags for :di #3395

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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