Skip to content

Function domain union syntax falls back to full real-line domain #1000

@dqnykamp

Description

@dqnykamp

Summary

<function> domains do not currently support union syntax in attribute text (for example domain="(-4,-1) union (1,4)").

When this syntax is used, parsing fails and the function falls back to an all-real-line domain.

Reproduction

<graph renderer="doenet" name="g">
  <shortDescription>test graph</shortDescription>

  <function domain="(-4,-1) union (1,4)">x^2</function>
</graph>

Actual behavior

  • The function appears defined everywhere.
  • The function's domain state value appears to be the full real line.
  • Warnings include:
    • Insufficient dimensions for domain for function. Domain has 0 intervals but the function has 1 input.
    • Invalid format for domain for function.

Expected behavior

For single-variable functions, union domains should be accepted and enforced, so the function is only defined on (-4,-1) ∪ (1,4).

Source analysis

Two places contribute to the fallback behavior:

  1. packages/doenetml-worker-javascript/src/components/IntervalList.js
  • breakEmbeddedStringsIntoIntervalPieces rejects non-whitespace tokens at top level, so union causes parse failure.
  1. packages/doenetml-worker-javascript/src/components/Function.js
  • Domain validation expects one interval per input dimension and only accepts trees with root "interval".
  • On mismatch/invalid format, it emits warnings and falls back to infinite domain.

Impact

This issue is in shared function domain state computation (not specific to a single renderer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions