Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Assigning an interface with additional properties to an interface with fewer properties fails #711

Open
3 tasks done
Luna-Klatzer opened this issue Nov 29, 2024 · 0 comments
Assignees
Labels
bug Bug or issue in the language or API
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

I am following the documentation's guide

  • I have read the documentation

This issue exists in the latest version

  • I am using the latest version

Current Behavior

Assigning an interface with additional properties to an interface with fewer properties fails. While this is common in some programming languages, this also goes against the duck typing principle that as long as all properties of an interface are present it is compatible, even if additional unrelated properties are present.

Expected Behavior

The assignment should work without error.

Steps To Reproduce

  1. Define one interface X with one property x: num
  2. Define one interface Y with the properties x: num and y: num (Y "extends" X and is compatible with it)
  3. Assign a value that is typed as Y to a variable with type X.

Example:

interface X {
	x: num;
}

interface Y {
	x: num;
	y: num;
}

var y: Y = {
	y: 1,
	x: 2,
};
var x: X = y;

Environment

  • Kipper: 0.12.0
  • Environment: Firefox Nightly 133.0b6
  • Operating System: Arch Linux
@Luna-Klatzer Luna-Klatzer added the bug Bug or issue in the language or API label Nov 29, 2024
@Luna-Klatzer Luna-Klatzer added this to the v0.13.0 milestone Nov 29, 2024
@Luna-Klatzer Luna-Klatzer self-assigned this Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or issue in the language or API
Projects
Development

No branches or pull requests

1 participant