Skip to content

Overloaded Union Constructors #12

@DavePearce

Description

@DavePearce

At the moment, constructors for union types generate custom classes. For example, this:

type union is int | int[]

Generates this class:

static class union {
		final private int tag;
		final private Object content;
		public union(BigInteger content) {
			this.tag = 0;
			this.content = content;
		}
		public union(BigInteger[] content) {
			this.tag = 1;
			this.content = content;
		}
		public boolean isBigInteger() {
			return this.tag == 0;
		}
		...
	}

This is fine, but note that the constructors overload based on the underlying type of each case. This causes problems if these types are the same. Note, even if the Whiley type differs, the underlying type can still be the same (for example, think about int:8 versus int:16).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions