[TS] Code generation error
- Dominant language
- TypeScript
- Stars
- 383
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
The following `derw` code defines a lambda of type `string -> string`.
```derw
main: string -> string
main = \name -> `Hello ${name}`
```
Running `derw compile` on this results in the following output:
```ts
function main(_0: string): string {
return function(name: any) {
return `Hello ${name}`;
};
}
```
which declares that main is a `string -> string` but in reality, `main: string -> any -> string` as is evident from the code.
However, using the regular function notation like so
```derw
main: string -> string
main name = `Hello ${name}`
```
fixes the problem:
```ts
function main(name: string): string {
return `Hello ${name}`;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Run the provided derw compile example and compare the lambda output with the regular function output. Trace the TypeScript code-generation path for typed lambdas; done means the generated function preserves the declared string-to-string type instead of introducing any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100