antlr/antlr4 · error · ArgumentNullException

set

Error message

set

What it means

Error "set" thrown in antlr/antlr4.

Source

Thrown at runtime/CSharp/src/Sharpen/BitSet.cs:215

            {
                int bit = BitScanForward(current);
                if (bit >= 0)
                    return bit + i * BitsPerElement;

                i++;
                if (i >= _data.Length)
                    break;

                current = _data[i];
            }

            return -1;
        }

        public void And(BitSet set)
        {
            if (set == null)
                throw new ArgumentNullException("set");

            int length = Math.Min(_data.Length, set._data.Length);
            for (int i = 0; i < length; i++)
                _data[i] &= set._data[i];

            for (int i = length; i < _data.Length; i++)
                _data[i] = 0;
        }

        public void Or(BitSet set)
        {
            if (set == null)
                throw new ArgumentNullException("set");

            if (set._data.Length > _data.Length)
                Array.Resize(ref _data, set._data.Length);

            for (int i = 0; i < set._data.Length; i++)

View on GitHub (pinned to 7d5770395b)

Solutions

  1. Pass a non-null BitSet to the set operation (And/Or/Xor/AndNot).
  2. Null-check the other set before combining.

Example fix

if (other != null) bits.Or(other);

When it happens

Trigger: BitSet set operation (Or/And/Xor/AndNot) called with a null set argument.

Common situations: Guard against null BitSet operands in set algebra calls.


AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14). Data as JSON: /api/errors/d57909b9c4434339. Report an issue: GitHub.