Files
Nim/tests/js
Copilot 83d7d8c634 Add test case for jsffi type mismatch error (#16726) (#25429)
Issue #16726 reported an internal compiler error (`semcall.nim(229, 18)
nArg != nil`) when calling `toJs` with invalid arguments. The bug has
been fixed in the current codebase but lacked a regression test.

```nim
import std/jsffi
let a = toJs(3)
let b = a.toJs(int)  # Now produces: Error: type mismatch
                      # Previously: internal error
```

**Changes:**
- Added `tests/js/t16726.nim` to verify proper type mismatch error is
reported instead of internal compiler error

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>internal error: semcall.nim(229, 18) nArg !=
nil</issue_title>
> <issue_description>### Example
> the code below should give a clean CT error, not an internal error
> ```nim
> import std/jsffi
> let a = toJs(3)
> let b = a.toJs(int)
> ```
> 
> ### Current Output
> nim r -b:js main
> compiler/semcall.nim(229, 18) `nArg != nil` 
> 
> ### Expected Output
> proper CT error
> 
> ### Additional Information
> 1.5.1 41965880ce
> </issue_description>
> 
> <agent_instructions>adds a test case for it and verify it by `./koch
temp js -r test.nim` before committing</agent_instructions>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> <comment_new><author>@ringabout</author><body>
> related:
https://github.com/nim-lang/Nim/issues/15607</body></comment_new>
> </comments>
> 


</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes nim-lang/Nim#16726

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2026-01-10 21:18:39 +08:00
..
2018-10-09 19:54:12 +02:00
2020-10-30 03:54:39 +01:00
2018-09-08 10:38:18 +02:00
2019-10-02 21:01:59 +02:00
2020-11-14 12:51:23 +01:00
2020-04-29 20:55:09 +02:00
2020-04-29 20:55:09 +02:00
2020-06-06 09:31:19 +02:00
2021-03-03 11:57:34 +01:00
2021-01-20 11:08:42 +01:00
2024-04-05 19:26:23 +08:00
2020-01-14 16:20:48 +01:00
2017-01-24 16:59:34 +01:00
2020-10-30 09:16:47 +01:00
2015-06-04 12:00:27 +03:00
2018-12-15 22:57:18 +01:00
2016-05-20 16:03:08 +06:00
2020-04-29 20:55:09 +02:00
2020-11-12 09:20:10 +01:00
2023-10-31 18:49:23 +01:00
2015-05-26 16:00:48 +03:00
2022-10-07 15:00:15 +02:00
2020-10-31 12:06:13 +01:00
2018-04-13 23:41:31 +02:00
2020-04-29 20:55:09 +02:00
2020-10-30 09:58:55 +01:00
2018-12-11 21:23:22 +01:00

notes

Prefer moving tests to a non-js directory so that they get tested across all backends automatically. Ideally, tests/js should be reserved to code that only makes sense in js.

Note also that tests for a js specific module (e.g.: std/jsbigints) belong to tests/stdlib, (e.g.: tests/stdlib/tjsbigints.nim)