Array types in function arguments
See original GitHub issueOverview
Array types should be acceptable function arguments. Currently, we do not have parser support for them.
Expected
A function can be declared with an array type as argument.
Actual
SyntaxError:
function testa(arr: i32[]): void {
^ Unexpected token Punctuator
Expected: "Identifier"
at testa (unknown.walt:7:23)
walt.js:3238:12
Acceptance Criteria
- Tests for the above case
- Tests pass
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Passing Arrays as Function Arguments in C - Tutorialspoint
If you want to pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in...
Read more >Passing Arrays as Function Arguments | SamanthaMing.com
If you want to pass an array into a variadic function. You can use ES6 spread to turn that array into a list...
Read more >7.7. Arrays And Functions
Arrays are always passed to functions (i.e., passed as function arguments) by pointer. With these concepts understood and reviewed as needed, we are...
Read more >Passing Array to a Function in C++ Programming - Programiz
In this tutorial, we will learn how to pass a single-dimensional and multidimensional array as a function parameter in C++ with the help...
Read more >The arguments object - JavaScript - MDN Web Docs - Mozilla
arguments is an Array-like object accessible inside functions that contains the values of the arguments passed to that function.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I want to clear something up. The goal is to use flow to accomplish a specific goal of using JavaScript syntax to write WebAssembly. Supporting most of flow would mean supporting most of JavaScript, which is unlikely.
The
Array<i32>
syntax does make sense if you expect flowtype to be re-implemented here. But re-implementing flow is not really a goal, simply a means to an end. I also wonder if there is a better argument made for the additional syntax other thanI prefer it over the other
because to me it’s not clear why either superior to the other.Having an
i32[]
syntax is good because it’s simple to implement and simple to understand and it’s rather stable at this point. I’d like to see this project move past the alpha stage and have some real-world examples out there before exploring additional syntax. Like @Baransu said having anArray<>
style syntax implies that there might be some generics-like stuff around, which there isn’t.Maybe we can add flow as a part of the compiler? As you said reimplementing it isn’t the goal but maybe we can leverage work that already been done. If we want to follow JavaScript and Flow syntax we can add flow as the first step of the validation. After that we will have the quarantee that we have correct typing so compiler can focus on more important things.