Skip to content

lsp: unprincipled mess of jump-to-definition #4283

@cuematthew

Description

@cuematthew

In the following all fields with numeric suffixes have the number purely for ease of discussion; they should be considered equal if the non-numeric part matches. E.g. f1 is the same field name as f2.

Currently:

	d: {f1: _} | {f2: _}
	d: f3: _
	e: d.f4

f1 resolves only to itself. f2 resolves only to itself. f3 resolves to {f1, f2, f3}. f4 resolves to {f1, f2, f3}. This is questionable: arguably f1 should resolve to {f1, f3}, and f2 should resolve to {f2, f3}. Because f1 MUST be unified with f3, and f2 MUST be unified with f3. But f3 MAY be unified with f1; it MAY be unified with f2.

If we change the | to &:

	d: {f1: _} & {f2: _}
	d: f3: _
	e: d.f4

now, f1, f2, f3 and f4 all resolve to {f1, f2, f3}. This seems right - all of these fields MUST be unified together.

For if/else:

	c: bool
	d: {
		if c {
			f1: _
		} else {
			f2: _
		}
	}
	
	d: f3: _
	e: d.f4

Unfortunately, here f1, f2 and f3 all resolve to {f1, f2, f3}. This seems very wrong: with the disjunction, we should probably avoid f1 and f2 resolving to each other, but here we should definitely avoid f1 and f2 resolving to each other.

I can see users wanting both MAY and MUST analysis. Currently, they reliably have neither. We currently use jump-to-definition. We could also start to make use of jump-to-declaration, and have one do the MUST and the other do a MAY.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions