Skip to content

Commit 30ca39b

Browse files
authored
Fix broken default dialect behaviour (#13)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 8a55bcf commit 30ca39b

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/ir/ir.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ auto compile(const sourcemeta::core::JSON &input,
2828
sourcemeta::core::SchemaTransformer canonicalizer;
2929
sourcemeta::core::add(canonicalizer,
3030
sourcemeta::core::AlterSchemaMode::Canonicalizer);
31-
[[maybe_unused]] const auto canonicalized{
32-
canonicalizer.apply(schema, walker, resolver,
33-
[](const auto &, const auto, const auto,
34-
const auto &) { assert(false); })};
31+
[[maybe_unused]] const auto canonicalized{canonicalizer.apply(
32+
schema, walker, resolver,
33+
[](const auto &, const auto, const auto, const auto &) { assert(false); },
34+
default_dialect, default_id)};
3535
assert(canonicalized.first);
3636

3737
// --------------------------------------------------------------------------

test/ir/ir_2020_12_test.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ TEST(IR_2020_12, test_1) {
2323
EXPECT_SYMBOL(std::get<IRScalar>(result.at(0)).symbol);
2424
}
2525

26+
TEST(IR_2020_12, default_dialect_parameter) {
27+
const sourcemeta::core::JSON schema{sourcemeta::core::parse_json(R"JSON({
28+
"type": "string"
29+
})JSON")};
30+
31+
const auto result{sourcemeta::codegen::compile(
32+
schema, sourcemeta::core::schema_walker,
33+
sourcemeta::core::schema_resolver, sourcemeta::codegen::default_compiler,
34+
"https://json-schema.org/draft/2020-12/schema")};
35+
36+
using namespace sourcemeta::codegen;
37+
38+
EXPECT_EQ(result.size(), 1);
39+
40+
EXPECT_IR_SCALAR(result, 0, String, "");
41+
EXPECT_SYMBOL(std::get<IRScalar>(result.at(0)).symbol);
42+
}
43+
2644
TEST(IR_2020_12, test_2) {
2745
const sourcemeta::core::JSON schema{sourcemeta::core::parse_json(R"JSON({
2846
"$schema": "https://json-schema.org/draft/2020-12/schema",

0 commit comments

Comments
 (0)