sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: TypeScript
Issue: Type narrowing down on a union type with null results in incorrect type when applying `typeof`
Labels: Bug

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms

type narrowing down, typeof

### 🕗 Version & Regression Information

I've tested all versions until 4.4.0 (Nightly)

### ⏯ Playground Link

https://www.typescriptlang.org/play?ts=4.4.0-dev.20210706#code/C4TwDgpgBAwg9gO2AQwJYIgJygXigbygGNEV0sAuA0SKgIgDM446BfKAH2vAnoCNkmNpygIArgBsJUVgFgAUAoZiERYKkRRgEAM7AAFOjBjgVeEjQZMASgIKoDqKgZRDCY8AB0JC+UwB+TxpoHFCoAHImOHDbfHtHBIB6RKgAdzhMAGsdeISHZCIiCDBgHQAxZjcPb1JLLGsAbly8gqKS8sr8YPootmtmpJSAEThdUThgNIzsgcdW4tKKuCqTGt8rKGQdLR44FyNVnzIrfvk8ucKFjuWunh7mYS2dyD2nd0Pav1OEuXlfpRUag0CE2l3aSxWpm4tCgjAerFirCAA

### 💻 Code
```typescript
type Container = { container: {type: "foo"} | {type: "bar"} | null }

function test(input: Container) {
    if (input.container?.type === 'foo') {
        // works
        acceptsFoo(input.container);
        acceptsFoo({type: "foo"})
        // Does not works
        acceptsFoo(input.container as typeof input.container)
        acceptsFoo({type: "foo"} as typeof input.container)
		/**
Error:
 Argument of type '{ type: "foo"; } | null' is not assignable to parameter of type '{ type: "foo"; }'.
  Type 'null' is not assignable to type '{ type: "foo"; }'.(2345) \
**/
    }
}

function acceptsFoo(input: {type: "foo"}) {}
```

### 🙁 Actual behavior

`input.container` and `input.container as typeof input.container` are not equivalent.

### 🙂 Expected behavior

`input.container` and `input.container as typeof input.container` should be equivalent.
Repository: react-native
Issue: Can't focus into text fields, Android + external keyboard
Labels: Platform: Android,Accessibility,Needs: Triage :mag:,Accessibility Team - Evaluated

In the first Expo example on https://reactnative.dev/docs/textinput - with an external physical keyboard on Android, we don't seem to be able to move the focus into/ between these input fields. It's fine if you tap the screen, and it's fine if Talkback is on and we alt+arrow between the fields. But with Talkback off, and just using the keyboard, we can't get focus into the fields.


## Expected Results
That the fields can be focussed by the keyboard

## Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/PT9eBWga1 (saved from the first example on https://reactnative.dev/docs/textinput)
Repository: neovim
Issue: Regression: dragging mouse with mouse=n goes to visual mode
Labels: bug-regression,mouse,has:bisected

<!-- Before reporting: search existing issues and check the FAQ. -->

- `nvim --version`:
```
NVIM v0.5.0
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim/src/neovim-0.5.0/build/config -I/build/neovim/src/neovim-0.5.0/src -I/usr/include -I/build/neovim/src/neovim-0.5.0/build/src/nvim/auto -I/build/neovim/src/neovim-0.5.0/build/include
Compiled by builduser

Features: +acl +iconv +tui
```
- Operating system/version: Arch Linux
- Terminal name/version: termite v15
- `$TERM`: xterm-256color

### Steps to reproduce using `nvim -u NORC`

* Go to normal mode
* `:set mouse=n`
* Drag the mouse from a line to another

### Actual behaviour ❌

It goes to visual mode and creates a selection. Then, mouse is disabled in visual mode, which is expected.

Video: https://ewd.xyz/c0c553.webm

### Expected behaviour ✔️

It moves cursor in normal mode and does not go to visual mode.

Video: https://ewd.xyz/3dbcbd.webm

### Additional notes ❗

This is a **regression** from Neovim v0.4.4 and Vim.

For the record, with `:set mouse=a`, when you drag the mouse, it goes to visual mode and selects text (expected and unchanged behavior).
Repository: create-react-app
Issue: Bundle Node.js dependencies at publish time
Labels: issue: proposal,needs triage

This is related to https://github.com/facebook/create-react-app/issues/11174.

Both Next.js and Vite bundle their build dependencies, where possible, at publish time. See:

- https://unpkg.com/browse/vite@2.4.1/dist/node/
- https://unpkg.com/browse/next@11.0.1/dist/
- https://github.com/vitejs/vite/blob/main/.github/contributing.md#notes-on-dependencies

We considered this early on but didn't do it. Maybe we should have. This would make https://github.com/facebook/create-react-app/issues/11174 a non-issue since there would simply be no dependencies in the tree to get alerts about. (If there's a real vulnerability, it can be filed against `react-scripts` itself.) It would also likely make startup faster and reduce the size of the dependency tree. It would, however, break customizations that rely on module hijacking. (Those would have to become forks.)

I think it's a promising direction and definitely worth investigating.
Repository: rust
Issue: array::map stack usage
Labels: A-LLVM,I-slow,T-compiler,I-heavy,A-array

I don't know if this is the right place for this, but I'd like to report that `array::map` uses the stack excessively and operating on larger arrays result in unexpected stack overflows.

Minimal example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=2d96e8f66b3432a8d1ecf0ca4331f85a

In the example, at some point more than 16 times more stack is used than the original array size.

As far as I've looked into the actual code, the only thing that stood out to me is use of `core::mem::transmute_copy` instead of `core::mem::transmute` in `core::array::IntoIter::new`, but I doubt it's the reason for this.

_Originally posted by @PonasKovas in https://github.com/rust-lang/rust/issues/75243#issuecomment-874732134_
Repository: rust
Issue: Unterminated block comment that contains /* anywhere, including in a doctest
Labels: C-enhancement,A-diagnostics,A-parser,T-compiler

I tried this code:

```rust
/**
to summon the cheerleader, use the following sequence: *\o/*
*/
pub fn cheerleader() {}
```
[https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=1a47ac30baafb8ad5bd90d566e00d4d9](playground)

(I actually encountered this when trying to document a router and included a doctest with a literal like `"/some/route/*"`, but the cheerleader is more fun)

I expected to see this happen: compilation success

Instead, this happened:
`error[E0758]: unterminated block doc-comment`
`Syntax Error: Missing trailing `*/` symbols to terminate the block comment [syntax-error]`

### Meta
This happens on all current rustc channels

I don't know if this is a bug or a "surprising feature" but with no knowledge of the implementation I would have expected the compiler to ignore text content including `/*` inside of a doc comment until the equivalent of the following regex is reached `/\n\s*\*\//`

Please let me know if this might be an approachable first contribution to rustc and I'll give it a shot
Repository: flutter
Issue: showing upgrade/download percentages while upgrading sdk
Labels: c: new feature,tool,platform-windows,c: proposal,P3,team-tool,triaged-tool

### we don't get much idea while `upgrading `sdk.

**_currently it shows like this:_**

![progress_status](https://user-images.githubusercontent.com/46500228/124645307-194f3400-deb5-11eb-908f-48be1140d2c9.png)

**wouldn't it be nice to have like this**


![lookingFor](https://user-images.githubusercontent.com/46500228/124645373-2c620400-deb5-11eb-9dbf-5064375a3a29.png)
Repository: godot
Issue: Curve of exactly 1.0 turns out to be 0.5
Labels: discussion,topic:shaders

### Godot version

df62d9f4f4910e94536c62c05f976b28703a9cc7

### System information

OpenSUSE, RX5500XT (Mesa 21.1.4)

### Issue description

curve works well 0 to 0.999 and 1.0 does not, below video

![image](https://user-images.githubusercontent.com/17591539/124645821-90c49980-de9c-11eb-92ad-11edb91c3204.png)


### Steps to reproduce


https://user-images.githubusercontent.com/17591539/124645498-2ca1d580-de9c-11eb-9fd1-031f38a0ea98.mp4


https://user-images.githubusercontent.com/17591539/124645501-2d3a6c00-de9c-11eb-992c-6e5f02ffe5e7.mp4



### Minimal reproduction project

[CurveVFX.tar.gz](https://github.com/godotengine/godot/files/6772954/CurveVFX.tar.gz)
Repository: deno
Issue: Support serializing blobs via structured clone
Labels: feat,web

Spec: https://www.w3.org/TR/FileAPI/#snapshot-state

Blocked on https://bugs.chromium.org/p/v8/issues/detail?id=11927
Repository: godot
Issue: Particles2D and CPUParticles2D Flickering Bug at Regular Intervals
Labels: bug,topic:rendering,needs testing,topic:2d,topic:particles

### Godot version

3.3.2.stable.official

### System information

Windows 10, Intel HD Graphics

### Issue description

Particles emitted by Particles2D and CPUParticles2D are not uniformly emitted/distributed, even when they should be as per settings. A 'flicker' can be seen at the source of the particles at regular intervals, and by setting the particles translucent it can be seem that the 'flicker' is infact particles not being uniformly emitted/distributed.

This happens when the particle velocity is set and the particles have _Local Coordinates_, and when there is no velocity and the particles don't have _Local Coordinates_ and the Particles2D / CPUParticles2D node is moving.

### Steps to reproduce

Create a **stream** (moving mass of offset particles) of overlapping (translucent if you want to see the bug better) particles and run the project.

### Minimal reproduction project

[Particles2D and CPUParticles2D Flicker.zip](https://github.com/godotengine/godot/files/6772128/Particles2D.and.CPUParticles2D.Flicker.zip)
The Sprite which doesn't move is a reference point to make it clear that it is the particles that are moving.
The inclusing of a _current_ Camera2D lets you see the bug for longer.
Repository: youtube-dl
Issue: youtube-dl failing to download from redtube
Labels: duplicate

It pulls down a JSON file rather than the video.   I suppose redtube is getting better ?
Repository: TypeScript
Issue: `Go to Definition for non-JS/TS files` doesn't respect `jsconfig.json`/`tsconfig.json`
Labels: Suggestion,Awaiting More Feedback

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->

v1.57 introduced [Go to Definition for non-JS/TS files](https://code.visualstudio.com/updates/v1_57#_go-to-definition-for-non-jsts-files), it works great for general relative path imports, but fails to resolve when the path is aliased.

Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->

- VS Code Version: v1.57.1
- OS Version: Windows 10

[Minimal Repro Link](https://github.com/wenfangdu/go-to-definition-repro)

```js
import './general.css' // 👈 works
import './src/aliased.css' // 👈 works
import '@/aliased.css' // 👈 fails
```
Repository: flutter
Issue: Hot restart/reload does not work if program is stuck in infinite loop
Labels: tool,t: hot reload,a: quality,has reproducible steps,P3,found in release: 2.2,team-tool,triaged-tool

```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

void loop() {
  while (true) {
    /* Do nothing */
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        ),
        body: Center(
          child: GestureDetector(
            onTap: loop,
            child: Container(
              child: Text('Hello World'),
            ),
          ),
        ),
      ),
    );
  }
}
```

Flutter version: 2.2.3 from stable channel
Repository: react
Issue: React 17/18 custom Synthetic Events
Labels: Type: Discussion,React 18

The Previous solution in #10135 no longer works for React 17 or React 18.

It would be really convenient to be able to craft events that react handles for custom inputs.

e.g. I have an accordion component and would like to add the ability to use it as an input, when the user clicks a button I'd like to dispatch a change event so their handlers get called.
Repository: PowerToys
Issue: Direct Indicator of which virtual desktop currently on
Labels: Idea-New PowerToy,Product-Virtual Desktop

### Description of the new feature / enhancement

I'm proposing a taskbar or OSD based desktop pager similar to that seen at the top of the Task View.  Some UI for this may be similar to:

- Taskbar based small pager just highlighting which desktop is active (seen in many FOSS desktops)
- Taskbar based small pager showing preview of each desktop (also seen in many FOSS desktops)
- Quake style dropdown similar to the upper pager of the Task View visible during transition via ctrl+left/ctrl+right navigation
- A simple OSD showing an accessible name for what specific desktop is currently selected

I currently have animations turned off and often remote desktop to windows systems where it may also be turned off.  Having no motion or pager to help establish which desktop is selected can be somewhat confusing.. hence why pagers are so popular outside of Windows/MacOS where virtual desktops are more of a norm.

Ultimately this may pave a way for windows to be dragged toward other desktops by way of the pager interface - which could in turn trigger fancyzones to reorient the window for that desktops preference.

### Scenario when this would be used?

As a local or remote desktop user needing a stronger indication of what desktop is currently selected without cycling through the desktops via the Task View.

### Supporting information


![image](https://user-images.githubusercontent.com/305301/124666960-39520980-de5b-11eb-8748-f3d539470c3b.png)
![image](https://user-images.githubusercontent.com/305301/124666832-1162a600-de5b-11eb-9626-1a6dec3c5c08.png)
Repository: PowerToys
Issue: When using multiple displays, make layout shortcut key in FancyZones work on: (i) all displays (ii) display with active focus, or (iii) display with mouse cursor.
Labels: Idea-Enhancement,Product-FancyZones

### Description of the new feature / enhancement

I propose that FancyZones apply the layout shortcut key to all displays by default and give the user the option to have it apply to only one display. If the user chooses to have it apply to one display, then the user should be able to choose whether it applies to the display with the mouse pointer or the display with active focus.

### Scenario when this would be used?

When I press the layout shortcut key in FancyZones while using multiple displays, the layout is applied to the monitor with the mouse pointer. This is problematic in two situations. The first occurs when I select an active display using alt+tab. The active display is often on a different display than the mouse pointer. After selecting the display using alt+tab, I press the FancyZones layout shortcut key (Win+Ctrl+Alt+[num]) with the expectation that it will apply the layout to the display with the active focus so I can then resize the active window. Instead, it applies the layout to the display with the mouse pointer. I must then move the mouse pointer to the correct display and press the layout shortcut key again.

The second situation occurs when I move a window from one display to another display using the Win+[arrow key] in FancyZones. I often need to change the layout on the display to which the active window is moved so I press the FancyZones layout shortcut key with the expectation that the layout will be applied to the display with the active window. Once again, the layout is applied to the display with the mouse cursor, which is not the one with the active window.

Please give us the option to have FancyZones apply the layout shortcut key to all displays, the display with the active focus, or the display with the mouse cursor.

I added a mockup of one way to implement this in the comments.

### Supporting information

_No response_
Repository: pytorch
Issue: The class weights implementation for loss functions is incorrect
Labels: module: nn,module: loss,triaged

## 🐛 Bug

The class weight implementation on a minibatch multiplies each data point's loss with the corresponding weight but then divides by the sum of the weights. This means that the contribution of the same data point to the overall loss is dependent on the other members in the batch which is not the right behavior. 

Concretely, for the Cross Entropy loss, the PyTorch way of doing it is

![Screenshot 2021-07-06 at 22 44 42](https://user-images.githubusercontent.com/8229727/124670442-e6547280-deab-11eb-9359-89d5bd99e080.png)

whereas the correct way (and the way Tensorflow does it) is

<img width="173" alt="Screenshot 2021-07-06 at 22 47 40" src="https://user-images.githubusercontent.com/8229727/124670664-37fcfd00-deac-11eb-932b-2b00ccdeaf56.png">


This issue is explained in more detail in 

https://towardsdatascience.com/class-weights-for-categorical-loss-1a4c79818c2d

## To Reproduce

Steps to reproduce the behavior:

1. Create some fake fake data, labels and weights
2. Compute F.cross_entropy(input_t,target_t,weight=weight_t)
3. Compute (-torch.nn.LogSoftmax(1)(input_t)[range(3),target_t]*weight[target_t]).sum()/weight[target_t].sum()

https://colab.research.google.com/gist/borundev/5440ad77464d01672cda7dff06d89ebc/class-weights.ipynb

## Expected behavior

I would expect the denominator in the expression to be the number of rows in the minibatch.

## Environment

PyTorch version: 1.9.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
CMake version: version 3.12.0
Libc version: glibc-2.26

Python version: 3.7.10 (default, May  3 2021, 02:48:31)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.4.104+-x86_64-with-Ubuntu-18.04-bionic
Is CUDA available: False
CUDA runtime version: 11.0.221
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.4
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.5
[pip3] torch==1.9.0+cu102
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.10.0
[pip3] torchvision==0.10.0+cu102
[conda] Could not collect

cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @ezyang @gchanan @zou3519 @bdhirsh @anjali411
Repository: go
Issue: cmd/link: -X on a constant, type, or func doesn't report an error
Labels: NeedsInvestigation,compiler/runtime

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.16.5 linux/amd64
</pre>

### Does this issue reproduce with the latest release?
yes


### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/path/to/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1151947343=/tmp/go-build -gno-record-gcc-switches"
</pre></details>

### What did you do?
```go
package main

import "fmt"

const Const = "one"

func Func() string { return "two" }

type Type struct{}

func main() {
	fmt.Println(Const, Func(), Type{})
}
```
```sh
go run -ldflags "-X=main.Const=three -X=main.Func=four -X=main.Type=five" .
```

### What did you expect to see?
```
main.Const: cannot set with -X: const not supported
main.Func: cannot set with -X: func not supported
main.Type: cannot set with -X: type not supported
```
### What did you see instead?
```
one two {}
```
Repository: godot
Issue: Vulkan: ORMMaterial3D has no way to adjust metallic specular (unlike StandardMaterial3D)
Labels: enhancement,discussion,topic:rendering,topic:3d

### Godot version

4.0.dev (7bd7b8f5e)

### System information

Fedora 34, GeForce GTX 1080 (NVIDIA 465.31)

### Issue description

Unlike StandardMaterial3D, ORMMaterial3D has no way to adjust the *specular* component of the metallic rendering. StandardMaterial3D provides additional control over metallic rendering this way. Changing this value from the default `0.5` is not physically accurate, but it can sometimes be useful to better simulate specific materials.

See also https://github.com/godotengine/godot/issues/50231.

### Steps to reproduce

- Create an ORMMaterial3D resource in the inspector dock.
- Look for a **Specular** property which would have been under the Metallic section with StandardMaterial3D.

### Minimal reproduction project

[test_orm.zip](https://github.com/godotengine/godot/files/6773042/test_orm.zip)