sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: TypeScript
Issue: Detect dead exports as well as per-module dead code
Labels: Suggestion,Awaiting More Feedback

## Search Terms

dead code

## Suggestion

Add a feature to detect dead code not just within modules, but within the build as a whole.

I've looked at https://github.com/Microsoft/TypeScript/issues/16939 which is currently locked so can't comment there. This really does need to be part of the Typescript compiler as no other program is really going to understand all the subtleties; the emitted JS doesn't contain all the information about interfaces and that kind of thing. Furthermore, this is not a file level operation- you're talking about tracking each individual interface/function/etc and not files. With these two factors it's no surprise that there are no current tools that can accomplish this- you would have to reimplement the compiler.

This would probably not be useful for library projects, as by definition things they export are not dead, therefore a separate compiler switch would be useful that application developers can enable.

The exact behaviour should be that exported top-level declarations may be considered "dead" if they are not visibly imported, as well as if they are not used from within the current module. The compiler will error on unused exports. The compiler should detect dynamic imports if the module path is hardcoded- the compiler already supports proper type inference in this case so feels like the compiler can already figure this one out.

This does not have to extend to properties/members of classes or anything like that- that can be a future improvement.

The compiler should ignore exports with a leading underscore, offer a built-in decorator to override a declaration as used, or both to handle any weird cases or entry points.

## Use Cases

We already detect dead code across individual files, but not across our whole project. We wish to do so across the entire project. We currently inspect runtime metadata of modules imported/exported as a unit test; unfortunately this is limited because TypeScript will emit modules that don't have any runtime code (e.g. just define an interface) but won't emit references to them. In addition, this approach can only detect whole modules as dead and not parts of them.

## Examples

The user would simply turn this on in their tsconfig.json, mark up the entry point for their app, then run the build.

## Checklist

My suggestion meets these guidelines:

* [*] This wouldn't be a breaking change in existing TypeScript/JavaScript code- existing users don't have to turn on the flag if they don't want to and it probably shouldn't be part of --strict either.
* [*] This wouldn't change the runtime behavior of existing JavaScript code
* [*] This could be implemented without emitting different JS based on the types of the expressions
* [*] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
* [*] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).
Repository: react
Issue: React callback ref cleanup function
Labels: Type: Discussion

At the time React added callback refs the main use case for them was to replace string refs. A lot of the callback refs looked like this:

```jsx
<div ref={node => this.node = node} />
```

With the introduction of `createRef` and `useRef` this use case is pretty much replaced by these alternatives so the use case of callback refs will shift to advanced use cases like [measuring DOM nodes](https://reactjs.org/docs/hooks-faq.html#how-can-i-measure-a-dom-node).

It would be nice if you could return a cleanup function from the callback ref which is called instead of the callback with null. This way it will behave more like the `useEffect` API.

```jsx
<div ref={node => {
  // Normal ref callback

  return () => {
    // Cleanup function which is called when the ref is removed
  }
}} />
```

This will be super helpful when you need to set up a Resize-, Intersection- or  MutationObserver.

```jsx
function useDimensions() {
  const [entry, setEntry] = useState()
  
  const targetRef = useCallback((node) => {
    const observer = new ResizeObserver(([entry]) => {
      setEntry(entry)
    })

    observer.observe(node)

    return () => {
      observer.disconnect()
    }
  }, [])

  return [entry, targetRef]
}

function Comp() {
  const [dimensions, targetRef] = useDimensions()

  return (
    <pre ref={targetRef}>
      {JSON.stringify(dimensions, null, 2)}
    </pre>
  )
}
```

Currently, if you want to implement something like this you need to save the observer into a ref and then if the callback ref is called with null you have to clean up the observer from the ref.

To be 99% backward compatible we could call both the callback ref with null and the cleanup function. The only case where it isn't backward compatible is if currently someone is returning a function and doesn't expect the function to be called.

```jsx
function ref(node) {
  if (node === null) {
    return
  }

  // Do something

  return () => {
    // Cleanup something
  }
}
```
Repository: kubernetes
Issue: Creating Kubemark cluster on GCE requires exporting environmental variables to work
Labels: kind/bug,sig/scalability,lifecycle/frozen

**What happened**:
Some environmental variables are not propagated, so creating a kubemark-based cluster on GCE requires exporting e.g. `KUBE_GCE_NETWORK` and `INSTANCE_PREFIX`. 

I suspect the problem is because of actual propagation (there are multiple layers of sourcing defaults when running `go run hack/e2e.go`) or there are some assumptions backed in.. 

**What you expected to happen**:
Defaults are set and propagated correctly, no need to state any variables, which can be inferred directly. 

**How to reproduce it (as minimally and precisely as possible)**:
Create cluster (I can paste an actual command, once I sanitize it). 

**Environment**: 
GCE

/sig scalability
Repository: node
Issue: http2: cannot negotiate ALPN besides http/1.1
Labels: help wanted,http2

The documentation for `'unknownProtocol'` says this:

> The `'unknownProtocol'` event is emitted when a connecting client fails to
negotiate an allowed protocol (i.e. HTTP/2 or HTTP/1.1). The event handler
receives the socket for handling. If no listener is registered for this event,
the connection is terminated.

The logic seems wrong though. It only passes through nothing (no protocol negotiated) or http/1.1, everything else is ignored:

https://github.com/nodejs/node/blob/11f8024d992c385d3db196ab64678311bfdabd84/lib/internal/http2/core.js#L2614-L2634

Caveat: if the check is loosened, care should be taken not to introduce an information leak.

For an attacker it should not be possible to deduce whether the server has `{ allowHTTP1: true }` and an `'unknownProtocol'` listener installed by sending messages with the ALPN proto set to `http/1.1` and e.g. `hax/13.37`, and then comparing the responses he gets back.
Repository: pytorch
Issue: [caffe2] Broken Operators Catalog
Labels: caffe2

## 📚 Documentation

The Operators Catalog only displays operators from APMeter to CountUp. 

https://caffe2.ai/docs/operators-catalogue.html
Repository: godot
Issue: source_code property of inner classes should return source.
Labels: bug,topic:gdscript,confirmed

3.1

The source_code property of scripts has been very helpful in parsing GDScripts dynamically for plugins. However when it comes to inner classes, the source_code will always return empty.

```
extends Node

class Example:
    func greet():
        print("Hello World")

func _ready():
    print(Example.source_code.empty())
```

Outputs true

Returning source_code for inner classes would be a huge benefit for more complex tool-making. It could also have the extra benefit of

`var source = Inner.get_base_script().source_code` 

making more sense if dealing with non-inner class parents.
Repository: TypeScript
Issue: Not possible to have optional object property compatible with both Closure Compiler and Intellisense
Labels: Suggestion,Needs Proposal

<!-- Please search existing issues to avoid creating duplicates. -->
<!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. -->
- VSCode Version: 1.32.3 x64
- OS Version: Ubuntu 18.04

Steps to Reproduce:
1. Enable "checkJs": true in jsconfig.json. 
2. Create a Javascript file:
```js
class A {

  /**
   * @param {{field: string|undefined}} obj 
   */
  constructor(obj) {
    this.obj = obj;
  }
}

let a = new A({});
```
Results in this error:
![image](https://user-images.githubusercontent.com/8695157/54741956-47af8500-4bc0-11e9-9873-ef9751b1965f.png)

Adding error text here for duplicate detection:
Argument of type '{}' is not assignable to parameter of type '{ field: string; }'.
 Property 'field' is missing in type '{}' but required in type '{ field: string; }' .ts(2345)

<!-- Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

Expected behaviour: 
Some way to mark object properties as optional compatible both with Closure Compiler and VsCode intellisense. Either through @typedef, through structural interfaces with @record, direct @param notation using string|undefined, or something similar. 

This notation works fine today, but it is not recognized by Closure Compiler. It is debatable whether this is an issue with Intellisense or lacking support from Closure Compiler.

```js
class A {

  /**
   * @param {AParam} obj 
   */
  constructor(obj) {
    this.obj = obj;
  }
}

/** @typedef {{field?: string|undefined}} */
var AParam;
let a = new A({});
```
Repository: go
Issue: proposal: x/net/nettest: add MakeLocalPipe to construct local listener and connections
Labels: Proposal

I'm currently implementing my own `net.Conn` type and am working on tests using `nettest.TestConn`: https://godoc.org/golang.org/x/net/nettest#TestConn.

The `nettest.MakePipe` function provides adequate functionality for my needs, but a fair amount of boilerplate is required to create a `nettest.MakePipe` that can:

- set up a local `net.Listener`
- dial and point a `net.Conn` at the listener
- do appropriate cleanup and error handling

As it turns out, there's a pretty useful function to make a local pipe in one of the tests: https://go.googlesource.com/net/+/refs/heads/master/nettest/conntest_test.go

I propose we generalize and export this function for use with `net.Listener` and `net.Conn` implementations of any type. I'm happy to accept name suggestions, but my proposed signature and WIP documentation is as follows:

```go
// MakeLocalPipe creates a local net.Listener and points another net.Conn at the
// listener, producing a MakePipe function suitable for use with TestConn.
// 
// The listen function should produce a net.Listener, but should not invoke Accept or
// any other methods on the listener. The dial function receives the address of the
// listener, and should produce a net.Conn pointed at the listener. If dial is nil,
// net.Dial will be invoked with the network and address information from addr.
func MakeLocalPipe(
    listen func() (net.Listener, error),
    dial func(addr net.Addr) (net.Conn, error),
) nettest.MakePipe
```

Usage is as follows:

Producing a local pipe with a TCP listener and connection, using net.Dial as a default dial function.
```go
nettest.TestConn(t, nettest.MakeLocalPipe(
    func() (net.Listener, error) {
        return net.Listen("tcp", ":0")
    },
    // dial: net.Dial(addr.Network(), addr.String())
    nil,
))
```

Producing a local pipe with a custom listener and connection implemented outside of the stdlib (https://github.com/mdlayher/vsock)
```go
nettest.TestConn(t, nettest.MakeLocalPipe(
    func() (net.Listener, error) {
        return vsock.Listen(0)
    },
    func(addr net.Addr) (net.Conn, error) {
        a := addr.(*vsock.Addr)
        return vsock.Dial(a.ContextID, a.Port)
    },
))
```

I don't mind putting this code in my own repository or similar if deemed unnecessary, but it seems like this would be an appropriate addition to `nettest`, since it enables easy setup of scaffolding for use with `nettest.TestConn`.

/cc @dsnet @mikioh
Repository: flutter
Issue: PageView with height based on current child
Labels: c: new feature,framework,d: stackoverflow,customer: crowd,P2,team-framework,triaged-framework

Is there a way a PageView can adapt to the size of the currently displayed item? 

I wan't to create something like a carousel, so I would use a PageView thats inside a Column or a ListView. However I can't give my PageView a constant height, because my items of the PageView have a variable height. 

[I have asked on Stackoverflow](https://stackoverflow.com/questions/54522980/flutter-adjust-height-of-pageview-horizontal-listview-based-on-current-child) a while ago but didn't get an answer.
Repository: rust
Issue: edition 2018 support for mod #[path=] attribute
Labels: A-resolve,T-lang,C-feature-request

If module files have edition 2018 style file structure and try to import one of them by path attribute:
```
#[path=modname.rs] 
mod modname;
```
compiler tries to find submodules in submodname.rs or submodname/mod.rs, but not in
**modname**/submodname.rs where it is really located.
Repository: pytorch
Issue: Doubly freed pointer in torch::cat error handling when called via pybind11.
Labels: module: cpp,module: error checking,triaged

## 🐛 Bug

Calling `torch::cat` with an illegal concatenation dimension in a pybind11-exposed C++ function results in a malloc error:

```
python3(47071,0x1147385c0) malloc: *** error for object 0x7f9e916be8d8: pointer being freed was not allocated
python3(47071,0x1147385c0) malloc: *** set a breakpoint in malloc_error_break to debug
```

## To Reproduce

Steps to reproduce the behavior:

1. Clone the code in the gist at https://gist.github.com/heiner/c03aa5df92408974922aea7ec499405c via `git clone https://gist.github.com/c03aa5df92408974922aea7ec499405c.git catbug`.
2. Run `cd catbug; python3 setup.py build develop`.
3. Run `python3 run.py`.

The relevant point in the backtrace is at
```
frame #4: 0x0000000119063f94 torchloops.cpython-37m-darwin.so`pybind11::cpp_function::dispatcher(self=0x0000000118df7b10, args_in=0x0000000118df5f60, kwargs_in=0x0000000000000000) at pybind11.h:691
   688 	            }
   689 	            PyErr_SetString(PyExc_SystemError, "Exception escaped from default exception translator!");
   690 	            return nullptr;
-> 691 	        }
   692
   693 	        auto append_note_if_missing_header_is_suspected = [](std::string &msg) {
   694 	            if (msg.find("std::") != std::string::npos) {
```

## Expected behavior

The underlying `c10::Error` should be raised in C++ and surfaced to the user.

## Environment

```
$ python3 collect_env.py
Collecting environment information...
PyTorch version: 1.0.0.dev20190313
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.14.3
GCC version: Could not collect
CMake version: version 3.12.2

Python version: 3.7
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] numpy==1.16.2
[conda] blas                      1.0                         mkl
[conda] mkl                       2019.1                      144
[conda] mkl-include               2019.1                      144
[conda] mkl_fft                   1.0.10           py37h5e564d8_0
[conda] mkl_random                1.0.2            py37h27c97d8_0
[conda] pytorch-nightly           1.0.0.dev20190313         py3.7_0    pytorch
[conda] torchgym                  0.0.0                     dev_0    <develop>
[conda] torchgymatari             0.0.0                    pypi_0    pypi
```
Repository: go
Issue: cmd/go: can't build go1.10 from source using go1.12
Labels: NeedsFix,modules

<!-- Please answer these questions before submitting your issue. Thanks! -->

### What version of Go are you using (`go version`)?

Go 1.12

### 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/matloob/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/matloob/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f4/9p58ddnj40x58zchdb36p7lr004_sl/T/go-build724269079=/tmp/go-build -gno-record-gcc-switches -fno-common"
</pre></details>

### What did you do?

I have Go 1.12 installed on my system. I cloned the go repo and checked out the tag go1.10.8.
Then i cd'd to the go repo's src directory and ran make.bash

### What did you expect to see?

a successful build

### What did you see instead?

matloob-macbookpro2:src matloob$ ./make.bash
Building Go cmd/dist using /usr/local/go.
go: cannot determine module path for source directory /Users/matloob/go110 (outside GOPATH, no import comments)

But make.bash *does work* when GO111MODULE is unset
Repository: rust
Issue: Move to using annotate-snippets-rs for producing snippets
Labels: C-enhancement,A-diagnostics,T-compiler,D-diagnostic-infra

@zbraniecki created https://github.com/zbraniecki/annotate-snippets-rs which basically does Rust-style formatting of code snippets for errors, to be used within [Fluent](http://github.com/projectfluent/fluent-rs).

I think we should try and move our snippet code out of tree, preferably merging it with annotate-snippets-rs (which is already close to what rustc does), so that it's reusable.

@zbraniecki has agreed to make whatever changes necessary to the crate to make it usable within rustc.

cc @estebank
Repository: TypeScript
Issue: No intellisense for require in ts files
Labels: Suggestion,In Discussion

**TypeScript Version:**  3.4.0-rc
**Search Terms:** require, intellisense

Typescript does not resolve modules of require expressions as it does in plain js files.

**Code**

```ts
require("s:\\dev\\easy-attach\\")({
    eagerExitDebugProxy: true,
    port: "preconfigured",
    
});
```

**Expected behavior:**
This is what I get in VS Code in plain js files:
![image](https://user-images.githubusercontent.com/2931520/54789524-07d5b580-4c33-11e9-9f4c-601b10f430c3.png)


**Actual behavior:**
However, the module is not resolved in ts files:
![image](https://user-images.githubusercontent.com/2931520/54789516-fdb3b700-4c32-11e9-8adb-9d59f44a2998.png)

Probably this is intended and my use case is a very special one.
However, typescripts repository description still says:

> TypeScript is a superset of JavaScript that compiles to clean JavaScript output. 

In this case, typescript has better support for `require` in `js` than in `ts` which is a little bit confusing considering typescript being a superset of javascript.
Repository: rust
Issue: Optimization regression in 1.32+
Labels: I-slow,A-codegen,E-needs-test,P-medium,T-compiler,regression-from-stable-to-stable,C-optimization

The following function:
```
pub fn num_to_digit(num: char) -> u32 {
    if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 }
}
```
With 1.31 produced the following:
```
  add edi, -48
  xor eax, eax
  cmp edi, 8
  cmovb eax, edi
  ret
```
Which looks reasonable, as `unwrap()` should never fail.
But in 1.32 and above it produces an unnecessary panic branch:
```
  push rax
  mov ecx, edi
  and ecx, -8
  xor eax, eax
  cmp ecx, 48
  jne .LBB0_3
  add edi, -48
  mov eax, edi
  cmp edi, 8
  jae .LBB0_2
.LBB0_3:
  pop rcx
  ret
.LBB0_2:
  lea rdi, [rip + .L__unnamed_1]
  call qword ptr [rip + _ZN4core9panicking5panic17h6f50c0de2dcd7974E@GOTPCREL]
  ud2
```

Interestingly, when I manually inline `is_digit`: https://github.com/rust-lang/rust/blob/89573b3c8b629507130b1ec8beeaf550fdc0e046/src/libcore/char/methods.rs#L58-L61
```
pub fn num_to_digit_fast1(num: char) -> u32 {
    if num.to_digit(8).is_some() { num.to_digit(8).unwrap() } else { 0 }
}
```
Or just use `unwrap_or`:
```
pub fn num_to_digit_fast2(num: char) -> u32 {
    num.to_digit(8).unwrap_or(0)
}
```
It produces good code on all compiler versions.

Godbolt instance I tested this on: https://godbolt.org/z/8yg7x0
Repository: react
Issue: Edge 18 & IE 11 server mismatch with SVG icons
Labels: Component: Server Rendering,Type: Needs Investigation

**Do you want to request a *feature* or report a *bug*?**

bug

**What is the current behavior?**

React raises a warning:

![Capture d’écran 2019-03-22 à 00 40 00](https://user-images.githubusercontent.com/3165635/54791630-0c05d100-4c3b-11e9-8426-4ea1ebb6e3f4.png)

https://codesandbox.io/s/k91nr3xzy5

```jsx
import React from "react";

export default () => (
  <div>
    2
    <svg>
      <path d="M0 0h24v24H0z" />
    </svg>
  </div>
);
```

**What is the expected behavior?**

No warning

**Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?**

React: 16.8.4
Browser: Edge 18
Repository: pytorch
Issue: [jit] Trace perform weirdly on BatchNorm
Labels: oncall: jit

## 🐛 Bug

I have use jit to trace a model which is based on ResNet. When the batch size of the input is 1, the result is correct. However, if the batch size is not 1, the result have a little difference. And I think it's caused by the different behavior of BatchNorm.

## To Reproduce
I use the code below.
```python
import torch
import torchvision

resnet = torchvision.models.resnet18(True)
resnet.eval()
traced_net = torch.jit.trace(resnet,torch.randn((3,3,224,224)))

traced_net.eval()

def check(inp):
    out1 = resnet(inp)
    out2 = traced_net(inp)
    return torch.sum(out1==out2)

for i in range(5):
    print(check(torch.randn((1,3,224,224))))
for i in range(5):
    print(check(torch.randn((3,3,224,224))))

#output
#tensor(1000)
#tensor(1000)
#tensor(1000)
#tensor(1000)
#tensor(1000)
#tensor(2009)
#tensor(2066)
#tensor(2119)
#tensor(2049)
#tensor(2023)
```

## Expected behavior

With the input shape of (3,3,224,224), the result should be 3*1000=3000, but it's just around 2000.

## Environment

PyTorch version: 1.0.1.post2
Is debug build: No
CUDA used to build PyTorch: 9.0.176

OS: Ubuntu 16.04.5 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
CMake version: version 3.13.1

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.0.176

[pip3] numpy==1.14.3
[pip3] numpydoc==0.8.0
[pip3] torch==1.0.1.post2
[pip3] torchvision==0.2.0
Repository: pytorch
Issue: [FR] support default size (scalar) in torch.randint
Labels: triaged,module: numpy,module: tensor creation,function request

## Motivation

This will be useful for people implementing stochastic algorithms and want the script to respect pytorch seed. np also has this.

cc @mruberry @rgommers