nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

`doc` command on a module importing `std/jsffi` and using a module config file (`<modulename>.nims`) causes error #21441

Closed quantimnot closed 1 month ago

quantimnot commented 1 year ago

Description

Running doc command on a module importing std/jsffi and using a module config file (<modulename>.nims) causes error.

Failing Examples

module.nim

discard """
matrix: "--backend:js doc"
"""
import std/jsffi

module.nims

# empty

Error

lib/system/jssys.nim(54, 1) Error: redefinition of 'getCurrentException'; previous declaration here: lib/system.nim(2430, 8)

module.nim

discard """
matrix: "doc"
"""
import std/jsffi

module.nims

--backend:js

Error

lib/system/jssys.nim(54, 1) Error: redefinition of 'getCurrentException'; previous declaration here: lib/system.nim(2430, 8)

Passing Examples

module.nim

discard """
matrix: "--backend:js doc"
"""
import std/jsffi

module.nims

Nim Version

1.6.10 ```nim --version Nim Compiler Version 1.6.10 [MacOSX: amd64] Compiled at 2023-02-12 Copyright (c) 2006-2021 by Andreas Rumpf active boot switches: -d:release ```
1.9.1-642136ec4f2cd93cdd753bf16fa4aec89b8fee82 ```nim --version Nim Compiler Version 1.9.1 [MacOSX: arm64] Compiled at 2023-02-09 Copyright (c) 2006-2023 by Andreas Rumpf git hash: 642136ec4f2cd93cdd753bf16fa4aec89b8fee82 active boot switches: -d:release -d:nimUseLinenoise ```

Current Output

No response

Expected Output

No response

Possible Solution

No response

Additional Information

No response

metagn commented 1 year ago

Fix might be to change defined(js) to defined(js) and not defined(nimscript) here:

https://github.com/nim-lang/Nim/blob/6fea221d65c999ef7923bf51bbdaa8421cb2e9df/lib/system.nim#L2219-L2221

Not defining js in nimscript is an option but I don't think there's any other way to tell if the current build is for javascript in a nimscript config file.