From 3d4ad504fec8f92421d2bb6205f5770e812bb422 Mon Sep 17 00:00:00 2001 From: Yan <62220457+likeamahoney@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:14:35 +0300 Subject: [PATCH] [slang] Make string simple type (#1049) --- source/ast/types/Type.cpp | 1 + tests/unittests/ast/MemberTests.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/source/ast/types/Type.cpp b/source/ast/types/Type.cpp index 781882f3c..8d9f45dfb 100644 --- a/source/ast/types/Type.cpp +++ b/source/ast/types/Type.cpp @@ -317,6 +317,7 @@ bool Type::isSimpleType() const { case SymbolKind::FloatingType: case SymbolKind::TypeAlias: case SymbolKind::ClassType: + case SymbolKind::StringType: return true; default: return false; diff --git a/tests/unittests/ast/MemberTests.cpp b/tests/unittests/ast/MemberTests.cpp index 37021e971..51983434b 100644 --- a/tests/unittests/ast/MemberTests.cpp +++ b/tests/unittests/ast/MemberTests.cpp @@ -2756,3 +2756,25 @@ endmodule ] })"); } + +TEST_CASE("IEEE 1800 Section 10.9.2 - structure assignment patterns") { + auto tree = SyntaxTree::fromText(R"( +module top; + typedef struct { + logic [7:0] a; + bit b; + bit signed [31:0] c; + string s; + } sa; + + sa s2; + initial s2 = '{int:1, default:0, string:""}; // set all to 0 except the + // array of bits to 1 and + // string to "" +endmodule +)"); + + Compilation compilation; + compilation.addSyntaxTree(tree); + NO_COMPILATION_ERRORS; +}