From 2ad0d1425a4053c56ffc87945a890b5bc89409fc Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 15 Jul 2021 14:55:32 -0400 Subject: [PATCH] compiler: Correct handling of TRUE matches There was a bug whereby TRUE matches would keep whatever value was being matched on, even if it was not a boolean. That was an oversight from the proof-of-concept code, and this fixes it; that's why this is behind a flag! This also adjusts the class aliasing optimization so that it doesn't check for a `TRUE` symbol name, which was a bad idea to begin with. This change also ends up expanding `lv:match[@value="TRUE"]` into the long form, where it didn't previously; this will result in slightly larger xmlo files in some cases, but it's nothing significant, and it does not impact compilation times. --- RELEASES.md | 8 +++++ src/current/compiler/js.xsl | 44 +++++++++++++++++++------- src/current/include/preproc/expand.xsl | 6 ++-- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 83c7905c..55b4f897 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -20,6 +20,14 @@ Compiler -------- - Make Summary Page less chatty. - Fix incorrect package name for generated worksheet packages. +- Restrict `TRUE`-match optimization to classification matches (class + composition). + - This was mistakenly not considering the domain of the match, and + therefore was applying the optimization in situations where it should + not. Results of previous classifications are currently the only place + we guarantee a boolean value. +- Apply classification alias optimization to any `1`-valued constant match. + - Previously applied only to `TRUE`. Summary Page ------------ diff --git a/src/current/compiler/js.xsl b/src/current/compiler/js.xsl index 8cc6f8c6..8c97de86 100644 --- a/src/current/compiler/js.xsl +++ b/src/current/compiler/js.xsl @@ -541,7 +541,6 @@ --> - -