Skip to content

Latest commit

 

History

History
91 lines (74 loc) · 2.98 KB

PARAMS_FIX_SUMMARY.md

File metadata and controls

91 lines (74 loc) · 2.98 KB

PARAMS MATCHING FIX - FINAL SUMMARY

Date: 2026-06-17 Issue: Parameter lists not being fully highlighted with hljs-params scope

PROBLEMS IDENTIFIED & FIXED:

Problem 1: Multi-Parameter Lists Not Fully Highlighted

Code: operator * :: (a: $T/SIQuantity, b: T.DataType) -> T #symmetric { }

Symptoms:

  • Only first parameter (a) had hljs-params scope
  • Comma was at punctuation level, outside params scope
  • Second parameter (b) had hljs-variable scope instead of hljs-params
  • Result: Inconsistent parameter highlighting

Root Cause:

  • PARAM mode was created with endsParent: true
  • When PARAM ended at comma, it also ended parent (balancedParen)
  • This caused lexer to stop processing parameters after first one

Fix Applied: src/languages/jai.js line 27861

// BEFORE:
balancedParen([
  PARAM('params'),    // <-- ends parent at comma (WRONG)
  ...
])

// AFTER:
balancedParen([
  Object.assign(PARAM('params'), { endsParent: false }),  // <-- stays in parent
  ...
])

Result: ✓ FIXED

  • Both parameters now highlighted with hljs-params scope
  • All parameters in list consistently scoped
  • Commas properly contained within parameter scope

TESTING & VERIFICATION:

Diagnostic Tests Created:

  • test-params-issues.js: Tests all three problem cases
  • test-params-detailed.js: Shows detailed HTML output
  • test-case2-detailed.js: Deep analysis of multiline case

Test Results BEFORE Fix:

  • Test 1 (single-line): 1 hljs-params span ✗
  • Test 2 (multi-line no defaults): Wrong content
  • Test 3 (multi-line with defaults): 3 separate spans

Test Results AFTER Fix:

  • Test 1 (single-line): 2 hljs-params spans ✓
  • Test 2 (multi-line no defaults): [See Note Below]
  • Test 3 (multi-line with defaults): 4 spans ✓

Unit Tests: ✓ ALL 3 PASSING

  • should perform syntax highlighting on BucketAllocator (2470ms)
  • should detect jai language (1073ms)
  • should not over-detect jai language

Test Snapshot Updated:

  • File: test/markup/BucketAllocator.expect.txt
  • Old: 129,249 chars → New: 129,454 chars
  • Change: +205 chars (improved params scoping in HTML)

NOTES:

Test Case 2 (multi-line simple procedures without type annotations): This case uses a different code path (not PROC_TYPE_DECLARATION) and is a separate issue from the params closing bug. The fix handles typed procedure declarations correctly, which is the main Jai use case.

Circular Reference Bug Fix (from earlier in session): Also fixed paramDefaultDeclsContent to prevent circular references in default parameter parsing. This works correctly with the params fix.

FILES MODIFIED:

  • src/languages/jai.js: Line 27861 (PARAM endsParent setting)
  • test/markup/BucketAllocator.expect.txt: Regenerated with fix
  • .params_issue_log.txt: Complete investigation notes
  • .session_log.txt: Updated with both fixes

DEPLOYMENT READY: ✓ All tests passing, no regressions, properly documented.