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

chore(developer): resolve excessive-fatal-exception issue #10949

Merged
merged 3 commits into from
Mar 12, 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
4 changes: 0 additions & 4 deletions developer/src/kmc-ldml/src/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,7 @@ export class LdmlKeyboardCompiler implements KeymanCompiler {
}
const sect = section.compile(globalSections);

/* c8 ignore next 7 */
if(!sect) {
// This should not happen -- validate() should have told us
// if something is going to fail to compile
this.callbacks.reportMessage(CompilerMessages.Fatal_SectionCompilerFailed({sect:section.id}));
passed = false;
continue;
}
Expand Down
8 changes: 3 additions & 5 deletions developer/src/kmc-ldml/src/compiler/messages.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { util, CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def, CompilerMessageSpecWithException } from "@keymanapp/common-types";
import { util, CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def } from "@keymanapp/common-types";
// const SevInfo = CompilerErrorSeverity.Info | CompilerErrorNamespace.LdmlKeyboardCompiler;
const SevHint = CompilerErrorSeverity.Hint | CompilerErrorNamespace.LdmlKeyboardCompiler;
const SevWarn = CompilerErrorSeverity.Warn | CompilerErrorNamespace.LdmlKeyboardCompiler;
const SevError = CompilerErrorSeverity.Error | CompilerErrorNamespace.LdmlKeyboardCompiler;
const SevFatal = CompilerErrorSeverity.Fatal | CompilerErrorNamespace.LdmlKeyboardCompiler;
// const SevFatal = CompilerErrorSeverity.Fatal | CompilerErrorNamespace.LdmlKeyboardCompiler;

/**
* @internal
Expand Down Expand Up @@ -59,9 +59,7 @@ export class CompilerMessages {
static Error_MustBeAtLeastOneLayerElement = () =>
m(this.ERROR_MustBeAtLeastOneLayerElement, `The source file must contain at least one layer element.`);

static FATAL_SectionCompilerFailed = SevFatal | 0x000F;
static Fatal_SectionCompilerFailed = (o:{sect: string}) =>
CompilerMessageSpecWithException(this.FATAL_SectionCompilerFailed, null, `The compiler for '${def(o.sect)}' failed unexpectedly.`);
// 0x000F - available

/** annotate the to= or id= entry */
private static outputOrKeyId(o:{output?: string, keyId?: string}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

<keys />

<!-- this is here because this test is used by test-compiler-e2e -->
<layers formId="us">
<layer id="base">
<row keys="a b c" />
</layer>
</layers>

<transforms type="simple">
<transformGroup>
<transform from="\u0127" to="x"/> <!-- fail: use \u{1234} instead -->
Expand Down
12 changes: 12 additions & 0 deletions developer/src/kmc-ldml/test/test-compiler-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,16 @@ describe('compiler-tests', function() {
]);
assert.isNotNull(kmx);
});
it('should fail on extra escapes - sections/tran/fail-bad-tran-2.xml', async function() {
const inputFilename = makePathToFixture('sections/tran/fail-bad-tran-2.xml');
const kmx = await compileKeyboard(inputFilename, { ...compilerTestOptions, saveDebug: true, shouldAddCompilerVersion: false },
[
CompilerMessages.Error_InvalidQuadEscape({ cp: 295 }),
],
true, // validation should fail
[
// compiler messages (not reached, we've already failed)
]);
assert.isNull(kmx); // should fail post-validate
});
});
1 change: 1 addition & 0 deletions developer/src/kmc-ldml/test/test-tran.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ describe('tran', function () {
],
},
{
// also used in test-compiler-e2e.ts
subpath: `sections/tran/fail-bad-tran-2.xml`,
errors: [
CompilerMessages.Error_InvalidQuadEscape({ cp: 295 }),
Expand Down
Loading