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

RecordInit with an alias-type and TypeAnnotationPrinter crashes #2196

Closed
quentin opened this issue Mar 1, 2022 · 2 comments
Closed

RecordInit with an alias-type and TypeAnnotationPrinter crashes #2196

quentin opened this issue Mar 1, 2022 · 2 comments

Comments

@quentin
Copy link
Member

quentin commented Mar 1, 2022

Hi,
The execution of this program crashes with the debug-report enabled: souffle -F- -D- mini.dl --debug-report out.html

.type t = [x:number]
.type a = t
.decl r(v:a)
.output r
r([1]).

I found this simple fix, but I'm not sure it is the root cause. Should the alias-type be already replaced by the aliased record-type here ?

--- a/src/ast/analysis/typesystem/Type.cpp
+++ b/src/ast/analysis/typesystem/Type.cpp
@@ -531,7 +531,11 @@ void TypeAnnotationPrinter::branchOnArgument(const Argument* cur, const Type& ty
     } else if (isA<NilConstant>(*cur)) {
         print_(type_identity<NilConstant>(), *as<NilConstant>(cur));
     } else if (isA<RecordInit>(*cur)) {
+        if (auto Aliased = as<AliasType>(type)) {
+        print_(type_identity<RecordInit>(), *as<RecordInit>(cur), *as<RecordType>(Aliased->getAliasType()));
+        } else {
         print_(type_identity<RecordInit>(), *as<RecordInit>(cur), *as<RecordType>(type));
+        }
     } else if (isA<BranchInit>(*cur)) {
         print_(type_identity<BranchInit>(), *as<BranchInit>(cur));
     } else if (isA<IntrinsicFunctor>(*cur)) {

Side-question, this program is not accepted (when debug-report is disabled):

Error: Ambiguous record in file mini.dl at line 6
r([1]).
--^-----
1 errors generated, evaluation aborted

Why is that ?

--EDIT: probably related to #2063

@quentin
Copy link
Member Author

quentin commented Mar 1, 2022

I eventually found that many uses of as<RecordType>(T) and isA<RecordType>(T) don't behave as expected when T is an alias-type. Maybe a similar issue exists with ADTs ?

-- EDIT: removed the diff, I am working on a better solution.

@quentin
Copy link
Member Author

quentin commented Mar 2, 2022

replaced by #2197

@quentin quentin closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant