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

Type casting with arrays does not work #14

Open
serkonda7 opened this issue May 5, 2023 · 1 comment
Open

Type casting with arrays does not work #14

serkonda7 opened this issue May 5, 2023 · 1 comment
Labels

Comments

@serkonda7
Copy link
Member

Description and Reproduction Steps

args := ['abc.txt', 'foo.md', 'bar.md']
md_files := []string(args.filter(fun (a string) bool {
	return a.ends_with(".md")
}))
for file in []string(md_files) {
}

Current Behavior

first snippet:

error: expression evaluated but not used

second snippet:

error: unexpected lpar, expecting lcur

Expected Behavior

No errors.

Possible Solution and Additional Information

It's planned to unify the casting syntax to var as Type.
Thus fixing this issue before is not advisable.

Bait version

Bait 0.0.2-dev

Environment details (OS name and version, Node.js version, etc.)

Arch Linux
Node 19.9.0

@serkonda7 serkonda7 added the bug label May 5, 2023
@serkonda7
Copy link
Member Author

Type casting on arrays should actually be forbidden except for matching type aliases:

type Arr := []i32

fun x(a Arr){
	println(typeof(a))
	println(a)
}

fun main() {
	n := [1,2] as Arr
	x(n)
	x([1,2] as Arr)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant